Skip to content

Commit

Permalink
Fixed #1718 - Improve dynamic mask on InputMask
Browse files Browse the repository at this point in the history
  • Loading branch information
mertsincan committed Jan 27, 2021
1 parent ca9c4d7 commit d655751
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/components/inputmask/InputMask.js
Expand Up @@ -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);
}
Expand All @@ -502,6 +504,8 @@ export class InputMask extends Component {
}

this.updateFilledState();

return pos;
}

isValueUpdated() {
Expand Down Expand Up @@ -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();
}
}
Expand Down

0 comments on commit d655751

Please sign in to comment.