-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
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] Add equivalent to openOnFocus for click
events
#23164
Comments
@pelletencate What's your use case for a new |
click
eventsclick
events
Should this rather be a single prop that handles both? Otherwise we should specify use cases for all combinations:
|
@eps1lon These combinations look valid. I have updated the proposal to |
It's trivial that these are valid. My point is what the use case for each of these combinations would be. |
|
These are the same? |
I think that we could bundle them under a single prop if the expected default behavior was identical for the two events. It's not the case. By default, the Autocomplete responds to click but not focus events. |
This is what I've been saying. Props, like components, should be declarative.
Why though? I don't see the distinction since depending on the user these are somewhat equivalent interactions. |
@eps1lon Initially, the behavior of the Autocomplete was Does it answer the question? |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@oliviertassinari Hey mind if i pick this issue up? |
@RiyaNegi Feel free to work on it. I have reread the thread, it seems to still be relevant and bring value. |
@oliviertassinari So just to be clear, we want a |
@RiyaNegi Correct |
@oliviertassinari Hey so I added the This was my solution, however if you have any suggestions for better implementation, do let me know. :) |
It seems to me the behavior requested can already be implemented in a controlled Autocomplete with open={open}
onOpen={(event) => {
if (event.type !== "mousedown" && event.type !== 'focus') {
setOpen(true);
}
}}
onClose={() => setOpen(false)} -- https://codesandbox.io/s/autocomplete-disableopenonclick-g0bt3?file=/src/Demo.tsx If that is the case, then we shouldn't bloat the interface and implementation for such a niche feature. |
@eps1lon @oliviertassinari Hey so I checked out your solution and it works, but it blocks the dropdown completely( doesn't open on either mouse click or focus). Also, the bigger issue is if you add --https://codesandbox.io/s/autocomplete-disableopenonclick-forked-g43i1?file=/src/Demo.tsx (demo with |
Fixed with -if (event.type !== "mousedown") {
+if (event.type !== "mousedown" && event.type !== 'focus') {
(true);
} |
@eps1lon @oliviertassinari I added your suggestion to the demo but it's not working. The dropdown doesn't open regardless of mouse click or focus. I know it's a niche case to be covering ( |
But that was the point of the codesandbox. People were asking for |
I think there is slight misunderstanding. The plan is to cover a case where both(
this is because when |
A reminder that this issue is still not clearly outlined. Currently it's ignored that a click causes a focus and how a conflict of There is no "intuitive" solution for this so we need to define clearer what the expected behavior is and how an API for that might look like. It sounds like we want to further split between keyboard-focus and click-focus. |
Use case for disable onClickOpen: you have freeSolo mode and user wants to type a new value, in a form the popup does cover the form inputs beneath and so the user has to click-away the popup. Maybe we should start try summerize use cases and figure out if they overlap or are the same? Not sure if that leads to some result, but if there isn't any better proposal, I start:
Probably not covering everything. This just the interaction with the input itself, the options for this use case behave always same, on select write the value to text box, select be via click or keyboard or touch. |
Summary 💡
openOnFocus does not affect what happens when an out-of-focus input is clicked. In the comments of #20286, it was argued that this is by design. As such, I hereby request an equivalent (suggested:
disableOpenOnClick
) prop that disables opening the suggestions on click.Motivation 🔦
I had to add this to the embedded TextField
The text was updated successfully, but these errors were encountered: