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] Ability to detect when user doesn't select an option #7330

Closed
m14t opened this issue Jul 3, 2017 · 1 comment
Closed

[AutoComplete] Ability to detect when user doesn't select an option #7330

m14t opened this issue Jul 3, 2017 · 1 comment
Labels
component: autocomplete This is the name of the generic UI component, not the React module!

Comments

@m14t
Copy link

m14t commented Jul 3, 2017

Description

Use case: We need an <AutoComplete /> that enforces that the value in that field is either empty or came from the auto-complete list.

In the current implementation of <AutoComplete /> onClose is called before onNewRequest. This makes it impossible to detect when a user hits esc or clicks away without selecting a value from the list.

Possible solutions

  1. If onClose was moved to be called after onNewRequest, users could implement an onUpdateInput method that would mark the input as "dirty", and a onNewRequest method that would mark the input as "clean". Then the onClose method could check if the input was clean or not, and update the value accordingly.

    I'm not sure if anyone is depending on the call order of onClose happening before onNewRequest and therefore if making this change would be desirable, or a breaking change.

  2. We could add a new optional onCancel callback to <AutoComplete /> that is called when the esc key or "click away" happens.

    This has the advantages of not changing existing functionality, is more explicit.

If this sounds like the type of thing this project would be interested in, I'd be more than happy to open a Pull Request with either direction.

@oliviertassinari
Copy link
Member

Closed by #4783

@oliviertassinari oliviertassinari added the component: autocomplete This is the name of the generic UI component, not the React module! label Apr 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: autocomplete This is the name of the generic UI component, not the React module!
Projects
None yet
Development

No branches or pull requests

2 participants