From 537552e1f409d6ce8eaf3c2e6c72ca1167a8178d Mon Sep 17 00:00:00 2001 From: Bahadir Sofuoglu Date: Sun, 4 Sep 2022 18:08:55 +0300 Subject: [PATCH] Password component default value display issue fixed --- src/components/password/Password.vue | 43 +++++++++++++++++++++------- 1 file changed, 33 insertions(+), 10 deletions(-) diff --git a/src/components/password/Password.vue b/src/components/password/Password.vue index ccdfe2b6c..dad70f5f3 100755 --- a/src/components/password/Password.vue +++ b/src/components/password/Password.vue @@ -100,6 +100,10 @@ export default { this.infoText = this.promptText; this.mediumCheckRegExp = new RegExp(this.mediumRegex); this.strongCheckRegExp = new RegExp(this.strongRegex); + if(this.value){ + this.d_value = this.value; + this.setPasswordMeter() + } }, beforeDestroy() { this.restoreAppend(); @@ -180,9 +184,34 @@ export default { onKeyUp(event) { if (this.feedback) { let value = event.target.value; - let label = null; - let meter = null; - switch (this.testStrength(value)) { + + const {meter,label} = this.checkPasswordStrength(value); + + this.meter = meter; + this.infoText = label; + if (!this.overlayVisible) { + this.overlayVisible = true; + } + } + + this.$emit('keyup', event); + }, + setPasswordMeter() { + if(!this.feedback) return; + + const {meter,label} = this.checkPasswordStrength(this.d_value); + + this.meter = meter; + this.infoText = label; + + if (!this.overlayVisible) { + this.overlayVisible = true; + } + }, + checkPasswordStrength(value) { + let label = null; + let meter = null; + switch (this.testStrength(value)) { case 1: label = this.weakText; meter = { @@ -208,15 +237,9 @@ export default { label = this.promptText; meter = null; break; - } - this.meter = meter; - this.infoText = label; - if (!this.overlayVisible) { - this.overlayVisible = true; - } } - this.$emit('keyup', event); + return { label, meter }; }, bindScrollListener() { if (!this.scrollHandler) {