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 triggers onSelect when pressing Enter while beforeAction is disabled and no option is in focus #11983

Open
abalejr opened this issue May 6, 2024 · 0 comments
Labels
Bug Something is broken and not working as intended in the system.

Comments

@abalejr
Copy link

abalejr commented May 6, 2024

Summary

When the beforeAction for Autocomplete is disabled, pressing Enter on the keyboard still triggers the onSelect callback, but with the content of the beforeAction minus the last character as the selected option. Subsequent presses of the Enter key select and deselect this value.

In the following reduced test case, the beforeAction is disabled if the inputValue is found among the labels of the Autocomplete options

Expected behavior

Pressing the Enter key while the beforeAction is disabled and no option is in focus should do nothing. Perhaps if the beforeAction becomes disabled and there are options shown, the first option should receive focus?

Actual behavior

Demo of problem
06-01-hrggv-skuuq.mp4

Steps to reproduce

Link to sandbox

  1. Type in some text that matches (case-sensitive) the label of one of the options (eg: Vinyl)
  2. Note that the beforeAction becomes disabled (expected)
  3. Note that clicking the beforeAction does nothing (expected)
  4. Note that pressing "Enter" on the keyboard triggers the onSelect callback with the content of the beforeAction minus the last character as the selected value (unexpected)
    • I've added some console.logs to better demonstrate this
  5. Note that pressing Enter again removes that value from selected

Are you using React components?

No

Polaris version number

12

Browser

Chrome

Device

M1 MacBook Pro

@abalejr abalejr added the Bug Something is broken and not working as intended in the system. label May 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something is broken and not working as intended in the system.
Projects
None yet
Development

No branches or pull requests

1 participant