@descope/web-components-ui 1.0.340 → 1.0.341

Sign up to get free protection for your applications and to get access to all the features.
@@ -3541,18 +3541,26 @@ const componentName$O = getComponentName('password');
3541
3541
 
3542
3542
  const customMixin$9 = (superclass) =>
3543
3543
  class PasswordFieldMixinClass extends superclass {
3544
- hidePasswordVisibility(input) {
3545
- // handle input element's type
3546
- input.setAttribute('type', 'password');
3547
- // handle vaadin's `password-visible` attribute
3548
- this.setAttribute('password-visible', 'false');
3549
- }
3550
-
3551
- showPasswordVisibility(input) {
3552
- // handle input element's type
3553
- input.setAttribute('type', 'text');
3554
- // handle vaadin's `password-visible` attribute
3555
- this.setAttribute('password-visible', 'true');
3544
+ init() {
3545
+ super.init?.();
3546
+
3547
+ this.handleCaretOnVisibilityChange();
3548
+ }
3549
+
3550
+ get caretPosition() {
3551
+ return this.value?.length || 0;
3552
+ }
3553
+
3554
+ handleCaretOnVisibilityChange() {
3555
+ const origTogglePasswordVisibility = this.baseElement._togglePasswordVisibility.bind(
3556
+ this.baseElement
3557
+ );
3558
+ this.baseElement._togglePasswordVisibility = () => {
3559
+ setTimeout(() => {
3560
+ origTogglePasswordVisibility();
3561
+ this.inputElement.setSelectionRange(this.caretPosition, this.caretPosition);
3562
+ });
3563
+ };
3556
3564
  }
3557
3565
 
3558
3566
  getAutocompleteType() {