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

Fix keyboard search when left pane is narrow #6303

Conversation

veekas
Copy link
Contributor

@veekas veekas commented Feb 22, 2023

First time contributor checklist:

Contributor checklist:

  • My contribution is not related to translations.
  • My commits are in nice logical chunks with good commit messages
  • My changes are rebased on the latest main branch
  • A yarn ready run passes successfully (more about tests here)
  • My changes are ready to be shipped to users

Description

Fixes #6281

This PR fixes Cmd+f/Ctrl+f functionality in the left pane. Using a keyboard to search across all
conversations should now automatically change the left pane width to accommodate the search input component.

I made an assumption that when a user searches globally, the behavior of the left pane should be similar to when a user searches within a single conversation.

To do so, I chose to create a new value in state called globalSearch. I'm not super happy with the name, but I don't have any better ideas. Another approach that seems to work and avoids adding a new value in state would be to assign any string to searchConversationId that doesn't match a real conversation, e.g. searchConversationId: 'global', but that seemed less clear than having a dedicated variable.

keyboard.search.mov

Other thoughts/bugs related to search

Although these are out-of-scope for this PR, I noticed a few things while working on this issue that I wanted to capture. I'll break these out into new issues later, assuming none of the Signal maintainers have strong feelings against the proposals.

  1. Deleting the conversation avatar (via clicking the 'x' or using the delete/backspace keys) when searching within a conversation could change the input field from a conversation search to a global search instead of closing the left pane immediately (assuming that the original width of the left pane was in its narrow state).
  2. Update other helpers (e.g. Stories and Compose) to work similarly to Inbox. Currently cmd+f doesn't give focus to the input field in any of the helpers other than LeftPaneInboxHelper
  3. SEARCH_CLEAR is getting called twice in a row when the user stops searching. I think it's getting called in both the onBlur and the onClear handlers in LeftPaneSearchInput.tsx (lines 101 and 118), but that should be validated.

@josh-signal josh-signal self-requested a review February 22, 2023 16:36
@josh-signal josh-signal self-assigned this Feb 22, 2023
@veekas veekas force-pushed the bug/keyboard-search-with-narrow-left-pane-6281 branch from 28bcd47 to 4156ce8 Compare February 22, 2023 19:21
This PR fixes Cmd+f/Ctrl+f functionality in the left pane.
Using a keyboard to search across all
conversations should now automatically change the left pane width
to accommodate the search input component.

Resolves: signalapp#6281
@veekas veekas force-pushed the bug/keyboard-search-with-narrow-left-pane-6281 branch from 4156ce8 to 0100866 Compare February 22, 2023 19:22
(state: SearchStateType): boolean | undefined => state.globalSearch
);

export const getIsSearchingGlobally = createSelector(
Copy link
Contributor

Choose a reason for hiding this comment

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

small nitpick but we probably don't need the above function we can just coerce into a Boolean right here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes sense. Updated!

@josh-signal
Copy link
Contributor

Awesome thanks, this will be in the next beta release

@josh-signal josh-signal merged commit 1258d31 into signalapp:main Feb 23, 2023
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.

Singal's Ctrl+F has broken
2 participants