Skip to content
This repository has been archived by the owner on Jun 28, 2021. It is now read-only.

Commit

Permalink
Merge pull request #79 from tleunen/textfield-dynamic-value
Browse files Browse the repository at this point in the history
fixes textfield not being updated if it received dynamically a value
  • Loading branch information
tleunen committed Oct 18, 2015
2 parents 52520fa + 6e69066 commit 009e700
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Textfield.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ class Textfield extends React.Component {
if(this.props.disabled !== prevProps.disabled) {
findDOMNode(this).MaterialTextfield.checkDisabled();
}
if(this.props.value !== prevProps.value && this.refs.input !== document.activeElement) {
findDOMNode(this).MaterialTextfield.change(this.props.value);
}
if(this.props.error && !this.props.pattern) {
// At every re-render, mdl will set 'is-invalid' class according to the 'pattern' props validity
// If we want to force the error display, we have to override mdl 'is-invalid' value.
Expand Down Expand Up @@ -63,6 +66,7 @@ class Textfield extends React.Component {
key: inputId,
value: value,
rows: rows,
ref: 'input',
...otherProps
};

Expand Down

0 comments on commit 009e700

Please sign in to comment.