Skip to content

Commit

Permalink
reinit value and buffer on mask change
Browse files Browse the repository at this point in the history
  • Loading branch information
murzvo committed May 8, 2017
1 parent 3198ae8 commit 30c34e1
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/MaskedField.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@ class MaskedField extends React.Component {
};
}

componentWillReceiveProps(nextProps) {
if (this.props.mask !== nextProps.mask) {
this.setState({value: ''}, function() { this._buffer = this._initialBuffer(); });
this._cursorPos = this._firstNonMaskIdx;
}
}

componentDidUpdate() {
if (this._cursorPos !== undefined) {
this._setSelection(this._cursorPos);
Expand Down

0 comments on commit 30c34e1

Please sign in to comment.