Skip to content

Commit

Permalink
Fixed #10174 - Password meter does not update dynamically
Browse files Browse the repository at this point in the history
  • Loading branch information
yigitfindikli committed Apr 28, 2021
1 parent 7fe0603 commit c0e26ec
Showing 1 changed file with 44 additions and 37 deletions.
81 changes: 44 additions & 37 deletions src/app/components/password/password.ts
Original file line number Diff line number Diff line change
Expand Up @@ -455,48 +455,52 @@ export class Password implements AfterContentInit,OnInit {
onKeyUp(event) {
if (this.feedback) {
let value = event.target.value;
let label = null;
let meter = null;

switch (this.testStrength(value)) {
case 1:
label = this.weakText();
meter = {
strength: 'weak',
width: '33.33%'
};
break;

case 2:
label = this.mediumText();
meter = {
strength: 'medium',
width: '66.66%'
};
break;

case 3:
label = this.strongText();
meter = {
strength: 'strong',
width: '100%'
};
break;

default:
label = this.promptText();
meter = null;
break;
}

this.meter = meter;
this.infoText = label;
this.updateUI(value);

if (!this.overlayVisible) {
this.overlayVisible = true;
}
}
}
}

updateUI(value) {
let label = null;
let meter = null;

switch (this.testStrength(value)) {
case 1:
label = this.weakText();
meter = {
strength: 'weak',
width: '33.33%'
};
break;

case 2:
label = this.mediumText();
meter = {
strength: 'medium',
width: '66.66%'
};
break;

case 3:
label = this.strongText();
meter = {
strength: 'strong',
width: '100%'
};
break;

default:
label = this.promptText();
meter = null;
break;
}

this.meter = meter;
this.infoText = label;
}

onMaskToggle() {
this.unmasked = !this.unmasked;
Expand All @@ -520,6 +524,9 @@ export class Password implements AfterContentInit,OnInit {
this.value = null;
else
this.value = value;

if (this.feedback)
this.updateUI(this.value || "");

this.cd.markForCheck();
}
Expand Down

0 comments on commit c0e26ec

Please sign in to comment.