Closed dhayab closed 1 month ago
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 7e5fbf58c0901cc70085c1e2476f2813283ecf4c:
Sandbox | Source |
---|---|
example-instantsearch-getting-started | Configuration |
example-react-instantsearch-getting-started | Configuration |
example-react-instantsearch-next-app-dir-example | Configuration |
example-react-instantsearch-next-routing-example | Configuration |
example-vue-instantsearch-getting-started | Configuration |
I guess it won't matter if it happens anywhere else? focus can still be lost on a link right?
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?
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