-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
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] Clicking on the GitHub input's demo is closing the popup #19836
Comments
@latoura Thanks for reporting this regression. |
@oliviertassinari After some investigations I don't think it's a regression. This behavior comes from the fact that the Customized Autocomplete example creates a function called In most of the examples the We can fix this behavior by just renaming Do you want me to make a PR to have a working example ? |
@Julien-Hery Thanks for the analysis of the problem. I think that this should be our baseline expectation: https://v4-5-2.material-ui.com/components/autocomplete/#customized-autocomplete. The problem I envision the onBlur approach is that it doesn't handle the Escape key. What do you think of this alternative: we introduce a diff --git a/docs/src/pages/components/autocomplete/GitHubLabel.tsx b/docs/src/pages/components/autocomplete/GitHubLabel.tsx
index 40e96300c..493767189 100644
--- a/docs/src/pages/components/autocomplete/GitHubLabel.tsx
+++ b/docs/src/pages/components/autocomplete/GitHubLabel.tsx
@@ -130,7 +130,11 @@ export default function GitHubLabel() {
setAnchorEl(event.currentTarget);
};
- const handleClose = () => {
+ const handleClose = (_, reason) => {
+ if (reason === 'toggleInput') {
+ return;
+ }
+
setValue(pendingValue);
if (anchorEl) {
anchorEl.focus(); |
@oliviertassinari Yes the 4.5.2 version is working as expected. I didn't thought about the escape key, good catch. The |
When using the Autocomplete component with custom template (like the GitHub Autocomplete in the Material-UI documentation), when the Popper is opened, the input is empty. Clicking on the empty input is closing the Popper instead of just getting the focus.
Current Behavior 😯
When using the Autocomplete inside a Popper, when the input is empty, clicking on it closes the Popper.
Expected Behavior 🤔
When using the Autocomplete inside a Popper, if the input is empty, clicking on it shouldn't close the Popper. It should just get the focus on the input. Even with autoFocus activated on the Input, users still try to click in the input before typing.
Steps to Reproduce 🕹
Steps:
Your Environment 🌎
You can reproduce this case directly on the Material-UI documentation
The text was updated successfully, but these errors were encountered: