From d65575153d34a23da16cc326de814c2b492e1296 Mon Sep 17 00:00:00 2001 From: mertsincan Date: Thu, 28 Jan 2021 00:30:16 +0300 Subject: [PATCH] Fixed #1718 - Improve dynamic mask on InputMask --- src/components/inputmask/InputMask.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/components/inputmask/InputMask.js b/src/components/inputmask/InputMask.js index 4411d56d84..63f478b4a3 100644 --- a/src/components/inputmask/InputMask.js +++ b/src/components/inputmask/InputMask.js @@ -481,19 +481,21 @@ export class InputMask extends Component { DomHandler.removeClass(this.input, 'p-filled'); } - updateValue() { + updateValue(allow) { + let pos; + if (this.input) { if (this.props.value == null) { this.input.value = ''; } else { this.input.value = this.props.value; - this.checkVal(); + pos = this.checkVal(allow); setTimeout(() => { if(this.input) { this.writeBuffer(); - this.checkVal(); + return this.checkVal(allow); } }, 10); } @@ -502,6 +504,8 @@ export class InputMask extends Component { } this.updateFilledState(); + + return pos; } isValueUpdated() { @@ -581,7 +585,7 @@ export class InputMask extends Component { if (prevProps.mask !== this.props.mask) { this.init(); - this.updateValue(); + this.caret(this.updateValue(true)); this.updateModel(); } }