Skip to content

[Autocomplete] Clicking anywhere on Input should open listbox#29500

Closed
hbjORbj wants to merge 4 commits intomui:masterfrom
hbjORbj:autocomplete-fix
Closed

[Autocomplete] Clicking anywhere on Input should open listbox#29500
hbjORbj wants to merge 4 commits intomui:masterfrom
hbjORbj:autocomplete-fix

Conversation

@hbjORbj
Copy link
Contributor

@hbjORbj hbjORbj commented Nov 4, 2021

Closes #29381

Problem:

  • Only clicking <input> inside InputBase div opens the list box. It is generally expected that clicking anywhere on the InputBase div should open the listbox.
  • preview: https://mui.com/components/autocomplete/
2021-10-30.11-15-40.mp4

Solution:

after.mov

@mui-pr-bot
Copy link

mui-pr-bot commented Nov 4, 2021

Details of bundle changes

Generated by 🚫 dangerJS against a010520

@hbjORbj hbjORbj added scope: autocomplete Changes related to the autocomplete. This includes ComboBox. type: new feature Expand the scope of the product to solve a new problem. labels Nov 4, 2021
@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged. label Nov 9, 2021
@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged. label Nov 11, 2021
@hbjORbj hbjORbj added type: regression A bug, but worse, it used to behave as expected. and removed type: new feature Expand the scope of the product to solve a new problem. labels Nov 11, 2021
onBlur: handleBlur,
onFocus: handleFocus,
onChange: handleInputChange,
onMouseDown: handleInputMouseDown,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I decided to use replace onMouseDown with onClick because this approach requires less change.

For example, when multiple is enabled, we pass onDelete: handleTagDelete() to Chips, which are used for multiple values. Chip's onDelete API uses a click event, so dealing with event bubbling gets more complicated.

Copy link
Member

@oliviertassinari oliviertassinari left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It breaks this demo https://deploy-preview-29500--material-ui.netlify.app/components/autocomplete/#playground

Screenshot 2021-11-11 at 17 31 10

Also, I'm not sure about triggering the popup on mouseup. It was done on mouseup to reproduce the <select> on macOS, select2, and react-select behaviors.

To be honest, I think that we could ignore the issue in the first place (I recall doing this in the past, not that it's not something that we want to fix, but more about it's a high effort item). For example, there are Autocomplete issues that are easier to solve with more traction from developers: e.g. #18450.

});
};

const { onClick: onInputClick, ...inputProps } = getInputProps();
Copy link
Member

@oliviertassinari oliviertassinari Nov 11, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This onClick prop fork seems to defeat the purpose of having getInputProps(). All the props were supposed to land on the same DOM element.

@hbjORbj
Copy link
Contributor Author

hbjORbj commented Nov 11, 2021

@oliviertassinari

Also, I'm not sure about triggering the popup on mouseup. It was done on mouseup to reproduce the <select> on macOS, select2, and react-select behaviors.

I agree with you on this point. It looks little laggy. I will explore other approaches.

@siriwatknp
Copy link
Member

@oliviertassinari

Also, I'm not sure about triggering the popup on mouseup. It was done on mouseup to reproduce the <select> on macOS, select2, and react-select behaviors.

I agree with you on this point. It looks little laggy. I will explore other approaches.

Have you figured it out?

@oliviertassinari oliviertassinari added the type: bug It doesn't behave as expected. label Jan 8, 2022
@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged. label Feb 21, 2023
@mnajdova
Copy link
Member

@hbjORbj what's the status here? Would be great to have the fix.

@sai6855
Copy link
Member

sai6855 commented Mar 9, 2023

i think #36369 PR also solving same issue

@mnajdova
Copy link
Member

i think #36369 PR also solving same issue

Correct, let's close this one.

@mnajdova mnajdova closed this Mar 23, 2023
@hbjORbj
Copy link
Contributor Author

hbjORbj commented Mar 23, 2023

Yes, we can close it

@oliviertassinari oliviertassinari removed the type: bug It doesn't behave as expected. label Apr 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PR: out-of-date The pull request has merge conflicts and can't be merged. scope: autocomplete Changes related to the autocomplete. This includes ComboBox. type: regression A bug, but worse, it used to behave as expected.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Autocomplete] Clicking Autocomplete's Input padding or Label doesn't open listbox

6 participants