Merge pull request #6407 from KumJungMin/fix/issue-6276
fix: emit unmask value to update:modelValue when unmask modepull/6480/head
commit
4e451e78b0
|
@ -1,7 +1,7 @@
|
||||||
<template>
|
<template>
|
||||||
<InputText
|
<InputText
|
||||||
:id="id"
|
:id="id"
|
||||||
:value="modelValue"
|
:value="currentVal"
|
||||||
:class="inputClass"
|
:class="inputClass"
|
||||||
:readonly="readonly"
|
:readonly="readonly"
|
||||||
:disabled="disabled"
|
:disabled="disabled"
|
||||||
|
@ -37,6 +37,11 @@ export default {
|
||||||
inject: {
|
inject: {
|
||||||
$pcFluid: { default: null }
|
$pcFluid: { default: null }
|
||||||
},
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
currentVal: ''
|
||||||
|
};
|
||||||
|
},
|
||||||
watch: {
|
watch: {
|
||||||
mask(newMask, oldMask) {
|
mask(newMask, oldMask) {
|
||||||
if (oldMask !== newMask) {
|
if (oldMask !== newMask) {
|
||||||
|
@ -60,7 +65,7 @@ export default {
|
||||||
if (this.androidChrome) this.handleAndroidInput(event);
|
if (this.androidChrome) this.handleAndroidInput(event);
|
||||||
else this.handleInputChange(event);
|
else this.handleInputChange(event);
|
||||||
|
|
||||||
this.$emit('update:modelValue', event.target.value);
|
this.updateModelValue(event.target.value);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onFocus(event) {
|
onFocus(event) {
|
||||||
|
@ -96,7 +101,7 @@ export default {
|
||||||
onBlur(event) {
|
onBlur(event) {
|
||||||
this.focus = false;
|
this.focus = false;
|
||||||
this.checkVal();
|
this.checkVal();
|
||||||
this.updateModel(event);
|
this.updateModelValue(event.target.value);
|
||||||
|
|
||||||
if (this.$el.value !== this.focusText) {
|
if (this.$el.value !== this.focusText) {
|
||||||
let e = document.createEvent('HTMLEvents');
|
let e = document.createEvent('HTMLEvents');
|
||||||
|
@ -133,18 +138,18 @@ export default {
|
||||||
|
|
||||||
this.clearBuffer(begin, end);
|
this.clearBuffer(begin, end);
|
||||||
this.shiftL(begin, end - 1);
|
this.shiftL(begin, end - 1);
|
||||||
this.updateModel(event);
|
this.updateModelValue(event.target.value);
|
||||||
|
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
} else if (k === 'Enter') {
|
} else if (k === 'Enter') {
|
||||||
// enter
|
// enter
|
||||||
this.$el.blur();
|
this.$el.blur();
|
||||||
this.updateModel(event);
|
this.updateModelValue(event.target.value);
|
||||||
} else if (k === 'Escape') {
|
} else if (k === 'Escape') {
|
||||||
// escape
|
// escape
|
||||||
this.$el.value = this.focusText;
|
this.$el.value = this.focusText;
|
||||||
this.caret(0, this.checkVal());
|
this.caret(0, this.checkVal());
|
||||||
this.updateModel(event);
|
this.updateModelValue(event.target.value);
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -203,7 +208,7 @@ export default {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.updateModel(event);
|
this.updateModelValue(event.target.value);
|
||||||
|
|
||||||
if (completed) {
|
if (completed) {
|
||||||
this.$emit('complete', event);
|
this.$emit('complete', event);
|
||||||
|
@ -420,7 +425,7 @@ export default {
|
||||||
var pos = this.checkVal(true);
|
var pos = this.checkVal(true);
|
||||||
|
|
||||||
this.caret(pos);
|
this.caret(pos);
|
||||||
this.updateModel(event);
|
this.updateModelValue(event.target.value);
|
||||||
|
|
||||||
if (this.isCompleted()) {
|
if (this.isCompleted()) {
|
||||||
this.$emit('complete', event);
|
this.$emit('complete', event);
|
||||||
|
@ -439,8 +444,11 @@ export default {
|
||||||
|
|
||||||
return unmaskedBuffer.join('');
|
return unmaskedBuffer.join('');
|
||||||
},
|
},
|
||||||
updateModel(e) {
|
|
||||||
let val = this.unmask ? this.getUnmaskedValue() : e.target.value;
|
updateModelValue(value) {
|
||||||
|
const val = this.unmask ? this.getUnmaskedValue() : value;
|
||||||
|
|
||||||
|
this.currentVal = value;
|
||||||
|
|
||||||
this.$emit('update:modelValue', this.defaultBuffer !== val ? val : '');
|
this.$emit('update:modelValue', this.defaultBuffer !== val ? val : '');
|
||||||
},
|
},
|
||||||
|
@ -448,7 +456,7 @@ export default {
|
||||||
if (this.$el) {
|
if (this.$el) {
|
||||||
if (this.modelValue == null) {
|
if (this.modelValue == null) {
|
||||||
this.$el.value = '';
|
this.$el.value = '';
|
||||||
updateModel && this.$emit('update:modelValue', '');
|
updateModel && this.updateModelValue('');
|
||||||
} else {
|
} else {
|
||||||
this.$el.value = this.modelValue;
|
this.$el.value = this.modelValue;
|
||||||
this.checkVal();
|
this.checkVal();
|
||||||
|
@ -458,11 +466,7 @@ export default {
|
||||||
this.writeBuffer();
|
this.writeBuffer();
|
||||||
this.checkVal();
|
this.checkVal();
|
||||||
|
|
||||||
if (updateModel) {
|
if (updateModel) this.updateModelValue(this.$el.value);
|
||||||
let val = this.unmask ? this.getUnmaskedValue() : this.$el.value;
|
|
||||||
|
|
||||||
this.$emit('update:modelValue', this.defaultBuffer !== val ? val : '');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}, 10);
|
}, 10);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue