-
Notifications
You must be signed in to change notification settings - Fork 169
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 recent searches keyboard navigation #4339
Conversation
28f0188
to
fb9a2e4
Compare
fb9a2e4
to
001719c
Compare
856cffe
to
3cf2b6a
Compare
3cf2b6a
to
d967e8d
Compare
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 mostly makes sense to me! A few things I noticed when running this locally:
- I'm not able to navigate to the "Clear" button from the search bar with the recent searches modal open using the
Tab
key. Is that intentional? - Similarly, when navigating through the recent searches, I'm not able to navigate to the
X
key usingTab
(theTab
key only iterates over entries). Is that expected as well?
// Keep `focused` as true when the user tabs out of the input. | ||
isInputFocused.value = false |
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 comment seems incongruous with the logic below, is it describing something else?
frontend/src/stores/search.ts
Outdated
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.
Are there any other functionality tests we should add for the new behavior added to this file?
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.
I added some tests for keyboard navigation.
d967e8d
to
0da60ab
Compare
It wasn't intentional, and is fixed now. Use arrows for navigating between the search entries, and tabs to move to "Clear" button and "Clear " buttons. |
e99e580
to
acaa322
Compare
@obulat please ping me when you think this is stable enough for final review! I don't want to review prematurely and miss any changes |
I think it's ready for review now |
I tried the testing steps locally and it doesn't seem like the current search shows up in the recent searches. If you also navigate to any of the recent searches, then tab out of the modal, the search text still remains as the recent search (rather than reverting to the current search). Are both of those intentional? |
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 as it fixes the linked issues well. to @AetherUnbound's points, I believe those are existing bugs we need to rectify. To clarify what those bugs are, and list some more:
- Homepage searches are not added to the recent search list 😢
- Hovering over recent searches updates the search input text (great!) but removing focus from the final choice doesn't clear the input state back to the original search term
- The recent search popup can not be closed with the keyboard when there are no recent searches. It relies on a focus loss of the "clear" button to hide itself and this is impossible when the clear button isn't displayed
- Recent searches can not be navigated into via the keyboard to focus their individual removal buttons
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.
Gotcha, thanks for that clarification Zack. LGTM otherwise!
I agree with @zackkrida's notes. A mockup/prototype showing the ideal flow could help align our expectations. And once we land on a solution, implement it throughout different PRs. What do you think of this idea? |
c4ca5d0
to
2f1c9fa
Compare
PR has undergone significant change
I wrote why I asked for a new review yesterday, but the comment didn't get posted. I refactored the way the recent searches are saved in the store, and most of the points from @zackkrida's message are fixed.
The way we used local storage in the search store was persisting the state intermittently. I tried different options, but the only one that worked consistently was to create a function that persists the recent searches by both setting the
Hovering does not update the input text, but selecting the options using arrow keys does (Google search box has the same behavior). Then, if you close the recent searches popover/modal using the "Back" button (in the narrow view), the "Escape" or "Enter" keys, the search is executed with the selected recent search.
The handler for hiding the recent searches when there are no recent searches wasn't working because the event handler wasn't falling through to the
You need to use the arrow keys to navigate to the recent search entries. But from there, you cannot navigate into the individual clear buttons. You can navigate into the individual removal buttons using "Tab" key on a narrow screen (they come after the main "Clear" button in the tabbing order), but not on desktop. @zackkrida, @AetherUnbound, could you re-review checking that the previous fixes are still working, and the 3 points here were also addressed.
|
5be9941
to
ee5fa3e
Compare
Signed-off-by: Olga Bulat <obulat@gmail.com>
Signed-off-by: Olga Bulat <obulat@gmail.com>
Signed-off-by: Olga Bulat <obulat@gmail.com>
Signed-off-by: Olga Bulat <obulat@gmail.com>
Signed-off-by: Olga Bulat <obulat@gmail.com>
Signed-off-by: Olga Bulat <obulat@gmail.com>
ce4e85f
to
f6c5a1f
Compare
I think this is the behavior that I'd expect, but if the current implementation is what makes the most sense than I won't block it! Edit: That said, having the current search in the recent searches makes the existing behavior much easier to deal with! |
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.
Thanks for the update, the current feature set is working well for me!
Right, I forgot to update the long text in the description to say that I re-added the current search to the recent searches. I looked at other examples of recent searches, and realized that if someone selected a different option, but wants to go back to the original search term, we need to have it in the options list. |
Based on the medium urgency of this PR, the following reviewers are being gently reminded to review this PR: @zackkrida Excluding weekend1 days, this PR was ready for review 5 day(s) ago. PRs labelled with medium urgency are expected to be reviewed within 4 weekday(s)2. @obulat, if this PR is not ready for a review, please draft it to prevent reviewers from getting further unnecessary pings. Footnotes
|
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.
I would've sworn I approved this last week. It's much improved; lgtm
Fixes
Fixes #3195 by @fcoveram
Fixes #480 by @obulat
Description
This PR refactors the way the keyboard navigation in a search layout on a narrow screen works.
I extracted non-related changes to other PRs, and will un-draft this PR when those PRs are merged.Some other related improvements in this PR are:
handleClear
andhandleClearSingle
functions were combined into one function with an optionalentry
argument. Ifentry
is passed to the function, only that entry is removed, otherwise, all recent search entries are removed.Testing Instructions
Run the app using
just frontend/run dev:only
, and openlocalhost:8443/search?q=cat
with a narrow screen.Try navigating on the page using the keyboard. If you get to the search input, and press
Tab
again, you will navigate to the content settings button, and then - to the main contain. In production, you will not be able to navigate to the content settings button because when you get inside the search input, the recent searches modal opens, and then you can only close it using the Back button at the right side of the search input.If you navigate using the keyboard to the search input, and then press a letter or an arrow key, the recent searches modal will open. Here, you can select one of the options using arrow keys. You can also clear recent searches by clicking "Clear all" or "Clear" cross button next to one of the recent searches.
When you click on the search input, the recent searches modal will open, and the cursur will be where you clicked (i.e, if you click in the middle of the search word, it will stay there and not move to the end of the search term as in prod"
Checklist
Update index.md
).main
) or a parent feature branch.just catalog/generate-docs
for catalogPRs) or the media properties generator (
just catalog/generate-docs media-props
for the catalog or
just api/generate-docs
for the API) where applicable.Developer Certificate of Origin
Developer Certificate of Origin