-
-
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
TextField loses focus when InputAdornment is clicked #16665
Comments
@ee92 This is the Google login form input, this seems like a great baseline to follow: The logic was lost in this diff 8b5cd6a#diff-3d0c58268ffed10a2bd03ed4b6799ebb. diff --git a/docs/src/pages/components/text-fields/InputAdornments.js b/docs/src/pages/components/text-fields/InputAdornments.js
--- a/docs/src/pages/components/text-fields/InputAdornments.js
+++ b/docs/src/pages/components/text-fields/InputAdornments.js
@@ -57,10 +57,6 @@ class InputAdornments extends React.Component {
this.setState({ [prop]: event.target.value });
};
- handleMouseDownPassword = event => {
- event.preventDefault();
- };
handleClickShowPassword = () => {
this.setState(state => ({ showPassword: !state.showPassword }));
};
@@ -130,7 +126,6 @@ class InputAdornments extends React.Component {
<IconButton
aria-label="Toggle password visibility"
onClick={this.handleClickShowPassword}
- onMouseDown={this.handleMouseDownPassword}
>
{this.state.showPassword ? <VisibilityOff /> : <Visibility />}
</IconButton> I can't find any motivation for this change in #12076. I would propose that we go in your direction, that we revert. Do you want to submit a pull request? :) |
@oliviertassinari I created PR (#16672) to revert the logic in the InputAdornment demos. Perhaps this should be a property of InputAdornment? Something like |
This solution does not work for me. The location of the element is lost in chrome, it goes back to the begining (but not on firefox, on firefox it works flawlessly). I attempted different ways, from focusing manually, but the location always goes back to the beggining. Google Chrome 80.0.3987.100 beta Tested on all of them, same behaviour.
|
Use |
Hi friends I am still having this problem
|
The new version of TextField loses focus when the InputAdornment is clicked. This seems undesirable.
Expected Behavior 🤔
The older (v1) TextField retains focus when Adornment is clicked:

Current Behavior 😯
The new TextField loses focus when Adornment is clicked:

Steps to Reproduce 🕹
Compare versions
v1: https://v1.material-ui.com/demos/text-fields/#input-adornments
v4: https://material-ui.com/components/text-fields/#input-adornments
Context 🔦
This behavior is annoying for password fields or any other field that the user might want to keep editing after clicking an adornment.
Your Environment 🌎
The text was updated successfully, but these errors were encountered: