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 flaky search behaviour with minimized left pane #6817

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

Conversation

smably
Copy link

@smably smably commented Mar 9, 2024

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 #6255

The search input had some weird and quirky behaviour when the left pane was minimized down to its minimum width:

  • When searching with CMD+F / CTRL+F, the left pane would expand but the search box wouldn't be focused
  • The only way to return the left pane to its collapsed state was to focus the search box, then move focus away from it, very awkward and hard to discover
  • If you typed in the search box and then backspaced until the input was empty, the left pane would collapse, hiding the search box (maybe you just made a typo and wanted to fix it?)
  • When searching within a conversation using CMD+SHIFT+F / CTRL+SHIFT+F, if you clicked the x next to the conversation icon, the left pane would collapse instead of switching to global search mode

I think it makes sense to collapse the left pane only when focus moves away from the search input and the search input is empty (i.e., no query and no conversation filter), so I implemented that and also made sure that the input receives focus when searching either globally or within a conversation.

Here's how global search looks now:

Screen.Recording.2024-03-08.at.11.10.52.PM.mov

And here's how conversation search looks:

Screen.Recording.2024-03-08.at.11.16.14.PM.mov

Here are the cases I manually tested:

  • When I hit CMD+F, the left pane opens with the global search box focused ✅
    • When I type and then backspace in the search box, the left pane stays expanded ✅
    • When focus leaves the search box but it is not empty, the left pane stays expanded ✅
    • When focus leaves the search box and it is empty, the left pane collapses ✅
    • When I hit ESC while in the search box, the left pane collapses ✅
  • When I hit CMD+SHIFT+F or click the magnifying glass in a conversation, the left pane opens with the conversation search box focused ✅
    • When I type and then backspace in the conversation search box, the left pane stays expanded ✅
    • When focus leaves the conversation search box, the left pane stays expanded even if the search box is empty because a conversation is selected ✅
    • When I click the x next to the conversation icon or hit ESC, the conversation icon disappears, the now global search box stays focused, and the left pane stays open ✅
      • From this point on, it behaves the same as the global search box above ✅

I updated the existing tests and they're all passing. Let me know if there are other tests I could write that would be valuable.

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.

If sidebar is at its thinnest state, activating search makes it so you cannot go back to lowest width
3 participants