Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow keyboard navigation in search results #5234

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jprask
Copy link

@jprask jprask commented May 9, 2021

First time contributor checklist:

Contributor checklist:

Description

Closes #5176.

Implement getConversationAndMessageInDirection for the search helper to allow users to browse search results with keyboard.

Couple things to note:

  1. When browsing trough unreads (alt + shift + arrow), messages will be ignored, because given the message search result data structure it's not possible to tell if it's unread or not. I went for the simple solution but suppose we could update the data, just let me know!

  2. When a message is selected, the focus changes to that message for about a second before coming back to the left panel, breaking the browsing flow if they press the navigation button too quickly while the message is still outlined. I think it would be preferable to still have the message highlighted somehow but keeping the focus on the results list, so the user can quickly browse trough messages but wanted to keep it simple for now but open to suggestions if/how that should be achieved.

  3. There is no visual indication of which item is active in the search left bar, so adding the selected state to the result items is probably the next step for the UX to be complete.

signal-nav-2

…archHelper

This allows user to navigate trough search results using the keyboard. Closes signalapp#5176.

The feature is more complex than one might initially think, due to the data structure for the messages being different of that from the conversations. This commit goes with the approach of figuring out if the next item in the navigation flow could be a message, then trying to find the next message and finally falling back to looking for the next conversation.

Another thing about the message data structure is that currently we can't check if it's unread, so in this commit when browsing trough unreads only the message results will be ignored.
Copy link
Contributor

@EvanHahn-Signal EvanHahn-Signal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for doing this.

I haven't looked at the code yet, but I think these two things must be addressed before we can merge (good catches, by the way):

  1. When a message is selected, the focus changes to that message for about a second before coming back to the left panel, breaking the browsing flow if they press the navigation button too quickly while the message is still outlined. I think it would be preferable to still have the message highlighted somehow but keeping the focus on the results list, so the user can quickly browse trough messages but wanted to keep it simple for now but open to suggestions if/how that should be achieved.

It feels like we need a way for the message to be highlighted without being focused. I think it's probably worth discussing the best way to do this. At a glance, it seems like it might be worth replacing selectedMessageId with something like this:

enum MessageSelectionMode {
  HighlightedButNotFocused,
  HighlightedAndFocused,
}

// ...

selectedMessage?: {
  mode: MessageSelectionMode;
  id: string;
};
  1. There is no visual indication of which item is active in the search left bar, so adding the selected state to the result items is probably the next step for the UX to be complete.

I think we need to do this. Could we compute this from the selectedConversation and selectedMessageId (or whatever the latter gets changed to)?

);
});

it('returns next message when going trough message list', () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

trough -> through

@jprask
Copy link
Author

jprask commented May 11, 2021

Thanks for looking at this @EvanHahn-Signal,

Could we compute this from the selectedConversation and selectedMessageId (or whatever the latter gets changed to)?

so I have a WIP commit that does that, but in some cases it runs into issues because the selectedMessageId eventually gets removed from the state. This seems related to the message outlining behavior on point no. 2 so I think if we address that then my implementation for highlighting the search result might be sufficient.

It feels like we need a way for the message to be highlighted without being focused. I think it's probably worth discussing the best way to do this. At a glance, it seems like it might be worth replacing selectedMessageId with something like this:

  enum MessageSelectionMode {
    HighlightedButNotFocused,
    HighlightedAndFocused,
  }
 
 // ...

 selectedMessage?: {
   mode: MessageSelectionMode;
   id: string;
 };

That looks like a nice api. For the implementation, I was initially thinking we would change the conversation state slice and have the conversation/message components react accordingly but digging a bit deeper it seems that the message highlighting happens here instead, so I think we just update the trigger call here to pass in the data structure you suggested and then update openConversation and focusConversation from inbox_view.js to account for that. If you see see any gotchas with this just let me know, in the meantime I'll be poking around with this approach in mind 😄

@EvanHahn-Signal EvanHahn-Signal changed the title Allow keyboard navigation trough search results Allow keyboard navigation in search results May 13, 2021
@hiqua
Copy link
Contributor

hiqua commented May 15, 2021

Does this implementation also cover the "new conversation" list (that can be opened via CTRL-N / pencil icon on the right of the search text area)? I was about to open a new issue, but maybe your PR fixes this already.

@jprask
Copy link
Author

jprask commented May 18, 2021

Does this implementation also cover the "new conversation" list (that can be opened via CTRL-N / pencil icon on the right of the search text area)? I was about to open a new issue, but maybe your PR fixes this already.

@hiqua I don't think so, I think for that we would implement getConversationAndMessageInDirection within a different helper. (perhaps LeftPaneComposeHelper here but it does have a comment saying it should not work in that helper).

However when we implement the selected item highlight here I believe it should work regardless of the helper being used so would be worth linking this PR if you create the new issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

Next / previous conversation keyboard shortcuts do not work in search results
4 participants