-
Notifications
You must be signed in to change notification settings - Fork 63
Hide the recent searches when navigating with the keyboard #1889
Conversation
Storybook and Tailwind configuration previews: Ready Storybook: https://wordpress.github.io/openverse-frontend/_preview/1889 Please note that GitHub pages takes a little time to deploy newly pushed code, if the links above don't work or you see old versions, wait 5 minutes and try again. You can check the GitHub pages deployment action list to see the current status of the deployments. |
Size Change: -2.52 kB (0%) Total Size: 820 kB
ℹ️ View Unchanged
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This solves the happy path problem, and I really love the size of this PR :)
One issue I found is if you navigate to the 'Clear' button, press Enter while on it, and then press Tab again, the recent searches does not close.
We could add a 'Tab' keydown handler to the Search Button and close the Recent searches if they are open.
@obulat since the Recent searches dialog come after the Search button in the tab order, if we always hid the recent searches when Tab is pressed on the Search button, the Clear button would become unreachable. So in f6d01f6 I've set the Search button Tab handler to only hide Recent searches if there are 0 entries. |
I knew there was a caveat! 😆 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's one more problem: if you click 'Clear', and then press 'Tab', you don't get to go to the Search button, and you don't trigger the Recent searches Tab handler (why?), so the popup remains open:
Recent.tab.mov
Should we immediately hide the popup when the 'Clear' button is pressed? That would fix this case. |
I wonder if hiding it after a short delay is better? This way, the users are not surprised when it is closed immediately, and might even have time to see that the list was emptied and that is why the popup closed? |
Alternatively, should the |
What if we focus the input when clicking the 'Clear' button? Then the user can 1. start typing the new value right away or 2. tab away and close the popover.
|
@obulat I tried your suggestion (almost verbatim, I realise now) and it works pretty well. The UX is pretty good and functionality-wise it does what one would expect. Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works well! 👍
It needs rebasing / merge now that ClientOnly is merged.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM but we also need to handle the case when tabbing backwards (to the Openverse logo), which currently keeps the popup open. A separate PR and issue is fine there.
Fixes
Fixes #1886 by @zackkrida
Description
This PR hides the recent searches when the keyboard focus moves past the 'Clear' button in the recent searches dropdown.
Testing Instructions
Screenshots
Screen.Recording.2022-10-07.at.8.48.12.AM.mov
Checklist
Update index.md
).main
) or a parent feature branch.Developer Certificate of Origin
Developer Certificate of Origin