From 30c34e1831ac4c017b2ba87eec9ed991a8ad2f6c Mon Sep 17 00:00:00 2001 From: Vladimir Murzak Date: Mon, 16 Jan 2017 19:14:55 +0200 Subject: [PATCH] reinit value and buffer on mask change --- src/MaskedField.jsx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/MaskedField.jsx b/src/MaskedField.jsx index 8133f37..aeeccf2 100644 --- a/src/MaskedField.jsx +++ b/src/MaskedField.jsx @@ -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);