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(useCombobox): ensure highlighted item is not selected on browser tab change #1484

Merged

Conversation

aliceHendicott
Copy link
Contributor

@aliceHendicott aliceHendicott commented Mar 13, 2023

What:

InputBlur action should return selectedItem only from Tab/Shift+Tab and not from clicking outside. However, before this change, if your click outside is to change browser tab, the current highlightedIndex is selected when returning to the page. This PR is to prevent that behaviour.

Fixes #1471.

How:

This PR updates the InputBlur handler on useCombobox to rely on the event.relatedTarget. In a blur event, this is set to the element receiving focus which is simply null when switching tabs because focus is no longer in that window.

Checklist:

  • Documentation N/A
  • Tests
  • TypeScript Types N/A
  • Flow Types N/A
  • Ready to be merged

@silviuaavram silviuaavram changed the title Ensure highlighted index is not selected on browser tab change (useCombobox) fix(useCombobox): ensure highlighted item is not selected on browser tab change Mar 14, 2023
@silviuaavram silviuaavram merged commit 4ff1385 into downshift-js:master Mar 14, 2023
@github-actions
Copy link

🎉 This PR is included in version 7.4.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

useCombobox selects highlightedIndex on browser tab change
2 participants