Code Monkey home page Code Monkey logo

Comments (7)

imran-yasin avatar imran-yasin commented on May 2, 2024

Check this Link
Hi, @AndreyOstrovnev

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

from material-ui.

ZeeshanTamboli avatar ZeeshanTamboli commented on May 2, 2024

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 renderInput callback of the Autocomplete.

from material-ui.

AndreyOstrovnev avatar AndreyOstrovnev commented on May 2, 2024

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:
Untitled

from material-ui.

imran-yasin avatar imran-yasin commented on May 2, 2024

@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 p tag

Check this Updated Version

from material-ui.

AndreyOstrovnev avatar AndreyOstrovnev commented on May 2, 2024

@imran-yasin I got your idea of fixing it, thanks for helping! There are still some places when the background area is clickable because p tag you added doesn't exactly match with outer tag added by MUI: <p class="MuiFormHelperText-root MuiFormHelperText-sizeMedium MuiFormHelperText-contained css-1wc848c-MuiFormHelperText-root" id="combo-box-demo-helper-text"> .... I achieved the expected behavior by moving out helper text completely out of Autocomplete component at the same level as a sibling. But the thing is for me it looked like a workaround of existing behavior.

from material-ui.

AndreyOstrovnev avatar AndreyOstrovnev commented on May 2, 2024

Hi @ZeeshanTamboli, since the issue is closed, I'm assuming there is no unexpected behavior and no plan to fix it?

from material-ui.

ZeeshanTamboli avatar ZeeshanTamboli commented on May 2, 2024

@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.

from material-ui.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.