-
Notifications
You must be signed in to change notification settings - Fork 151
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
Ability to set form fields as invalid #72
Comments
released in 1.1.0 |
I can't seem to get this working 🤔 . Setting |
It seems to set it for the first render, but then MDC removes the class |
A few things on this:
Does this sound like whats happening to you? |
I'm able to reproduce it on the TextField doc page, by just changing the first TextField to add invalid:
You will see that it at first is red, then write something, click somewhere else (unfocus), click back. It now is no longer invalid |
Back to my original point, that is what is called an uncontrolled input. React doesn't re-render it after its first render. A more meaningful example. class MyComponent extends React.Component {
render() {
return (
<div>
{/* This will lose its invalid state when you type. There is nothing to be done about that since material-web-components is removed the className and deciding what is valid or not based on the html5 pattern attribute. */}
<TextField invalid label="Uncontrolled Input"/>
{/* This will one wont because react will re-render it every time you type and reapply the invalid class */}
<TextField invalid label="Controlled Input" value={this.state.myVal} onChange={evt => this.setState({value: evt.target.myVal})}/>
</div>
)
}
} |
This is in reference to #60, there should be a way to set form fields as invalid.
The text was updated successfully, but these errors were encountered: