From 9a336c1274f93c536f57dc1818249e1bb466c520 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B3=E5=BD=A5=E6=9D=B1?= Date: Thu, 6 Mar 2025 14:42:28 +0800 Subject: [PATCH] Update InputMask.vue fix InputMask when use unmask and in certain cases (empty string), will show wrong value --- packages/primevue/src/inputmask/InputMask.vue | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/packages/primevue/src/inputmask/InputMask.vue b/packages/primevue/src/inputmask/InputMask.vue index 385489a18..98e5d9416 100755 --- a/packages/primevue/src/inputmask/InputMask.vue +++ b/packages/primevue/src/inputmask/InputMask.vue @@ -454,10 +454,24 @@ export default { return unmaskedBuffer.join(''); }, + unmaskValue(value) { + let unmaskedBuffer = []; + let thisbuffer = value.split(''); + + for (let i = 0; i < thisbuffer.length; i++) { + let c = thisbuffer[i]; + + if (this.tests[i] && c !== this.getPlaceholder(i)) { + unmaskedBuffer.push(c); + } + } + + return unmaskedBuffer.join(''); + }, updateModelValue(value) { if (this.currentVal === value) return; - const val = this.unmask ? this.getUnmaskedValue() : value; + const val = this.unmask ? this.unmaskValue(value) : value; this.currentVal = value;