Skip to content
This repository was archived by the owner on Aug 7, 2025. It is now read-only.

Commit fea820c

Browse files
committed
reinit value and buffer on mask change
1 parent 5c5cd9b commit fea820c

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/MaskedField.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,12 @@ const MaskedField = React.createClass({
4444
value: propsValue ? this._maskedValue(propsValue) : ''
4545
};
4646
},
47+
componentWillReceiveProps(nextProps) {
48+
if (this.props.mask !== nextProps.mask) {
49+
this.setState({value: ''}, function() { this._buffer = this._initialBuffer(); });
50+
this._cursorPos = this._firstNonMaskIdx;
51+
}
52+
},
4753
componentDidUpdate() {
4854
if (this._cursorPos !== undefined) {
4955
this._setSelection(this._cursorPos);

0 commit comments

Comments
 (0)