-
Notifications
You must be signed in to change notification settings - Fork 523
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(refinement-list): re-apply focus on facet checkbox after render #6392
Conversation
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 7e5fbf5:
|
packages/instantsearch.js/src/components/RefinementList/RefinementList.tsx
Show resolved
Hide resolved
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.
fix looks like a good workaround for now.
- is this happening anywhere else? What makes refinement list special that it doesn't need to be fixed somewhere else? no form elements in other components?
- test should be in CTS, maybe for all components?
packages/instantsearch.js/src/components/RefinementList/__tests__/RefinementList-test.tsx
Outdated
Show resolved
Hide resolved
I guess it won't matter if it happens anywhere else? focus can still be lost on a link right? |
The loss of focus happens with all refinement widgets. I'm on the fence about adding this extra code to all widgets. It makes more sense for the refinement list as it allows proper toggling with the keyboard. Wdyt? |
Summary
In InstantSearch.js, focus is lost when toggling a facet value in a refinement list. This is because the component is destroyed and re-created during re-render, and Preact does not explicitly refocus the newly created component (whereas React does it).
This PR adds code that stores the last refined value and applies focus to its DOM element on re-render.
CR-6976