@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.
package/dist/index.esm.js CHANGED
@@ -3453,18 +3453,26 @@ const componentName$D = getComponentName('password');
3453
3453
 
3454
3454
  const customMixin$7 = (superclass) =>
3455
3455
  class PasswordFieldMixinClass extends superclass {
3456
- hidePasswordVisibility(input) {
3457
- // handle input element's type
3458
- input.setAttribute('type', 'password');
3459
- // handle vaadin's `password-visible` attribute
3460
- this.setAttribute('password-visible', 'false');
3461
- }
3462
-
3463
- showPasswordVisibility(input) {
3464
- // handle input element's type
3465
- input.setAttribute('type', 'text');
3466
- // handle vaadin's `password-visible` attribute
3467
- this.setAttribute('password-visible', 'true');
3456
+ init() {
3457
+ super.init?.();
3458
+
3459
+ this.handleCaretOnVisibilityChange();
3460
+ }
3461
+
3462
+ get caretPosition() {
3463
+ return this.value?.length || 0;
3464
+ }
3465
+
3466
+ handleCaretOnVisibilityChange() {
3467
+ const origTogglePasswordVisibility = this.baseElement._togglePasswordVisibility.bind(
3468
+ this.baseElement
3469
+ );
3470
+ this.baseElement._togglePasswordVisibility = () => {
3471
+ setTimeout(() => {
3472
+ origTogglePasswordVisibility();
3473
+ this.inputElement.setSelectionRange(this.caretPosition, this.caretPosition);
3474
+ });
3475
+ };
3468
3476
  }
3469
3477
 
3470
3478
  getAutocompleteType() {