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

AutoComplete: onSelect incorrectly called on mouse down, resulting in two selections #7412

Open
inad9300 opened this issue Nov 13, 2024 · 0 comments
Labels
Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible

Comments

@inad9300
Copy link
Contributor

inad9300 commented Nov 13, 2024

Reproducer

https://stackblitz.com/edit/drzc4t?file=src%2FApp.jsx

Steps to reproduce the behavior

  1. Open the console
  2. Write "tea" in the input box
  3. Click and hold "black tea"
  4. See how "tea" is reported as selected!
  5. Release the click
  6. "black tea" is now reported as selected, as expected – but it is too late, the onSelect callback has already run and done all the side effects it needed, only with the wrong item

To complicate matters further, if you are adding elements to a list above the autocomplete element on select, the autocomplete and its dropdown will be pushed down as you click down, such that the element that you were going to click is no longer under the cursor, and nothing else is selected when you release the click, so only the undesired item ends up selected.

@inad9300 inad9300 added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Nov 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible
Projects
None yet
Development

No branches or pull requests

1 participant