diff --git a/projects/ui/src/lib/components/po-field/po-password/po-password.component.spec.ts b/projects/ui/src/lib/components/po-field/po-password/po-password.component.spec.ts index f74433c6c2..ef746ca2c8 100644 --- a/projects/ui/src/lib/components/po-field/po-password/po-password.component.spec.ts +++ b/projects/ui/src/lib/components/po-field/po-password/po-password.component.spec.ts @@ -41,6 +41,16 @@ describe('PoNumberComponent:', () => { expect(component.type === 'password').toBeTruthy(); }); + it('should set autoComplete with value `new-password` if noAutocomplete is true', () => { + component.noAutocomplete = true; + expect(component.autocomplete).toBe('new-password'); + }); + + it('should set autoComplete with value `on` if noAutocomplete is false', () => { + component.noAutocomplete = false; + expect(component.autocomplete).toBe('on'); + }); + describe('Properties:', () => { it('p-hide-password-peek: should update property with valid values.', () => { const validValues = [false, true, '', 'false', 'true']; diff --git a/projects/ui/src/lib/components/po-field/po-password/po-password.component.ts b/projects/ui/src/lib/components/po-field/po-password/po-password.component.ts index 4b3ce8cb11..534da23c8e 100644 --- a/projects/ui/src/lib/components/po-field/po-password/po-password.component.ts +++ b/projects/ui/src/lib/components/po-field/po-password/po-password.component.ts @@ -1,5 +1,5 @@ -import { AbstractControl, NG_VALIDATORS, NG_VALUE_ACCESSOR } from '@angular/forms'; import { ChangeDetectionStrategy, ChangeDetectorRef, Component, ElementRef, forwardRef, Input } from '@angular/core'; +import { AbstractControl, NG_VALIDATORS, NG_VALUE_ACCESSOR } from '@angular/forms'; import { convertToBoolean, uuid } from '../../../utils/util'; import { PoInputGeneric } from '../po-input-generic/po-input-generic'; @@ -50,6 +50,7 @@ export class PoPasswordComponent extends PoInputGeneric { visiblePassword = false; private _hidePasswordPeek?: boolean = false; + private _noAutocompletePassword?: boolean = true; /** * @optional @@ -68,6 +69,14 @@ export class PoPasswordComponent extends PoInputGeneric { } } + @Input('p-no-autocomplete') override set noAutocomplete(value: boolean) { + this._noAutocompletePassword = convertToBoolean(value); + } + + override get noAutocomplete() { + return this._noAutocompletePassword; + } + get hidePasswordPeek(): boolean { return this._hidePasswordPeek; }