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(refinement-list): re-apply focus on facet checkbox after render #6392

Merged
merged 6 commits into from
Oct 21, 2024

Conversation

dhayab
Copy link
Member

@dhayab dhayab commented Oct 17, 2024

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

Copy link

codesandbox-ci bot commented Oct 17, 2024

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:

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

@dhayab dhayab marked this pull request as ready for review October 17, 2024 16:18
@dhayab dhayab requested review from a team, sarahdayan, shaejaz and Haroenv and removed request for a team October 17, 2024 16:18
Copy link
Contributor

@Haroenv Haroenv left a 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?

@Haroenv
Copy link
Contributor

Haroenv commented Oct 18, 2024

I guess it won't matter if it happens anywhere else? focus can still be lost on a link right?

@dhayab
Copy link
Member Author

dhayab commented Oct 18, 2024

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?

@dhayab dhayab marked this pull request as draft October 18, 2024 14:09
@dhayab dhayab marked this pull request as ready for review October 21, 2024 13:36
@dhayab dhayab merged commit 17e6658 into master Oct 21, 2024
14 checks passed
@dhayab dhayab deleted the fix/refinement-list-keyboard-focus branch October 21, 2024 13:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants