-
-
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
[material-ui][Autocomplete] click on helperText inside of Autocomplete component triggers input focus/option selection #41931
Comments
Check this Link I've use the propagation method to stop the parent (Autocomplete) from reacting when you click on the child ( that is the TextField ). Now nothing should happen, clicking underneath input. Thanks |
Thanks for the solution, @imran-yasin. @AndreyOstrovnev, the issue occurs because the helper text is rendered within the Text Field component (using the FormHelperText component). Therefore, clicking on the helper text is treated as clicking on the Text Field itself. Following @imran-yasin's solution to stop the event propagation should resolve this issue. If that doesn't work, consider rendering the input component and FormHelperText component separately in the |
Hi @imran-yasin, thanks for the solution but your fix disables the event only on text. The content of helperText is wrapped in "p" tag which is still causes focus on input. So clicking right next to helper text will still trigger focus event. E.g. here: |
@AndreyOstrovnev Thank you for pointing that out! To prevent the focus event from being triggered when clicking next to the helper text, we need to apply the event handler to the entire helper text area, including the surrounding Check this Updated Version |
@imran-yasin I got your idea of fixing it, thanks for helping! There are still some places when the background area is clickable because |
Hi @ZeeshanTamboli, since the issue is closed, I'm assuming there is no unexpected behavior and no plan to fix it? |
@AndreyOstrovnev, upon further consideration, I agree with your assessment. Rendering the helper text separately from the input seems like the best approach. As demonstrated in the following demo: https://mui.com/material-ui/react-text-field/#helper-text, clicking on the helper text does not focus the input. This issue is duplicate of #26153. So I am marking it as a duplicate. Follow #26153 for more updates. |
Steps to reproduce
Link to live example: link
Steps:
helper text area:
Current behavior
Autocomplete input is focused, option selection area is opened
Expected behavior
I'm expecting nothing should happen, clicking underneath input should not cause input focus
Context
No response
Your environment
No response
Search keywords: Autocomplete
The text was updated successfully, but these errors were encountered: