-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
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] Form autofill doesn't update floating label text on textfield #718
Comments
This is probably a good place to start... |
@illogikal could you post of gif that? |
Mm, that's interesting. @mbrookes Do you know if it's for all input types or just password inputs? |
Not sure - I tried swapping the order of address and password, but autofill didn't fire, either to fill in a known user/password, or to save a new one. I'll have to figure out how best to test other fields. |
Okay, I plan on revisiting refactoring some of the TextField stuff in the near future. I'll try to experiment a bit too. Let me know if you notice anything else. |
Hello! We're running into this issue. Is there anything we can do locally to try and experiment w/ some potential fixes for this? Or is it going to have to wait on a refactor? |
We have the exact problem with the password field listed above. In addition to that we have a similar problem with a plain |
That looks like a different issue. |
that code could be added to |
Any idea, guys? |
Experiencing the same issue. |
Is there a way to disable autofill that works with MUI? |
http://stackoverflow.com/questions/15738259/disabling-chrome-autofill |
any solution to fire onChange event ? |
@antoinerousseau Is this going to be merged in master? |
This might be a similar issue (same root cause, different manifestation?) I'm not seeing the animation issues as mentioned, but the height of the TextField container does not take into account the top margin on the input. This results in the TextField extending 14px below the container. It's a fairly straightforward workaround, but I'm only seeing it with autocomplete: |
nice @nathanmarks, thanks!! and did you find a hack to update the floating label when chrome autofills without clicking the page, too? |
This is still a pretty painful issue. I tried using vanilla-autofill-event which just didn't work. I'm using When I added an hidden username and password fields chrome ignored the entire form (unless hiding them with display:none which chrome didn't care about). So I used 4 ( 😞 ) extra fields. 2 to make chrome ignore my form (autocomplete=off didn't work) and 2 more in a different fake form to make chrome fill, than in componentDidMount I added a timeout that copied the values from the fake fields to the real ones using redux-form change event: class Login extends Component {
// This was tested under chrome only. It's ugly, but it works. Code was modified a bit for simplicity so it might not work out of the box.
componentDidMount() {
// Fix chrome auto-fill
setTimeout(() => {
const { change, dispatch }= this.props;
if (this.refs.usernameAutoFill.value && ! this.refs.username.value) {
dispatch(change('username', this.refs.usernameAutoFill.value));
}
if (this.refs.passwordAutoFill.value && !this.refs.password.value) {
dispatch(change('password', this.refs.passwordAutoFill.value));
}
}, 500);
}
render() {
const styles = {
autofill: {
height: 0,
width: '1px',
position: 'absolute',
left: 0,
top: 0
}
};
return (
<div>
<form style={styles.autofill}>
<input type="text" ref="usernameAutoFill" name="usernameAutoFill" />
<input type="password" ref="passwordAutoFill" name="passwordAutoFill" />
</form>
<form autocomplete="off">
<div style={styles.autofill}><input type="text" name="fakeusername" /><input type="password" name="fakepassword" /></div>
<Field name="username" component={() => <TextField ref="username" name="username" floatingLabelText="Username" />}/>
<Field name="password" component={() => <TextField ref="password" name="password" type="password" floatingLabelText="Password" />}/>
<RaisedButton primary={true} label="Login" type="submit"/>
</form>
</div>
)
}
}
export default {
Form: reduxForm({
form: 'Login'
})(Login)
} I've modified the code for simplicity so use it just for reference. |
There is a css solution to this bug
|
Can you please explain what this means ? |
:-webkit-autofill selects autofilled fields by browser. Place your label right next to input and select it with :-webkit-autofill selector. If you need more help please share your current html structure. |
Sure! Here is my HTML Please help. Thanks |
Your labels come right after the inputs, so you dont have to do anything with html.
|
Uh, @kishan3 I think you're lost. MDL is this way --> google/material-design-lite#4827 😆 (Although given that MDL is dead Jim, perhaps you've come to the right place after all!) |
Ah damn! Its confusing with names. 😆 @mbrookes One question though: can we use material UI directly into HTMLs with CDN links? I never realised MDL is dead 😢 |
What's the solution? |
This issue concerns v0.x. |
This comment has been minimized.
This comment has been minimized.
If anyone is still here, I just set this prop |
@tom-con thanks man, it worked for me perfectly |
|
This is a v0.x issue (2015), please refer to #14427. |
@ozturkcangokkaya Hi this css solution works fine in Chrome. But when i check my form in firefox, floating label is not working. Do you have any idea why webkit-autofill affects firefox? |
Please see #14427 for v4. |
This comment has been minimized.
This comment has been minimized.
Thank you, I am using this:
|
I solved my problem installing lodash.merge on my project then I realised I was filling the text field component incorrectly it was because I thought the redux behaves should be the same when I use nested objects. As you can see, I am not filling correctly when I mixing two nested objects. |
Note that the latest version of Material-UI (v4.9.0) supports it by default. |
This still seems to be an issue on Windows Chrome. The label is not shrinking when the field is autofilled (happening not just on password but also on a field with Shouldn't this be addressed in MUI itself, so we don't have to do workarounds? |
When you use chrome to autofill text fields, the floating label text doesn't animate and show at all (as of 0.8.0)
The text was updated successfully, but these errors were encountered: