diff --git a/libs/vault/src/cipher-form/components/autofill-options/autofill-options.component.spec.ts b/libs/vault/src/cipher-form/components/autofill-options/autofill-options.component.spec.ts index f1bb1ef942b..6cc9d704831 100644 --- a/libs/vault/src/cipher-form/components/autofill-options/autofill-options.component.spec.ts +++ b/libs/vault/src/cipher-form/components/autofill-options/autofill-options.component.spec.ts @@ -39,7 +39,8 @@ describe("AutofillOptionsComponent", () => { beforeEach(async () => { getInitialCipherView.mockClear(); - cipherFormContainer = mock({ getInitialCipherView, formStatusChange$ }); + cipherFormContainer = mock({ getInitialCipherView }); + cipherFormContainer.formStatusChange$ = formStatusChange$.asObservable(); liveAnnouncer = mock(); platformUtilsService = mock(); domainSettingsService = mock(); @@ -266,6 +267,23 @@ describe("AutofillOptionsComponent", () => { expect(component.autofillOptionsForm.value.uris.length).toEqual(1); }); + it("does not emit events when status changes to prevent a `valueChanges` call", () => { + fixture.detectChanges(); + + const enable = jest.spyOn(component.autofillOptionsForm, "enable"); + const disable = jest.spyOn(component.autofillOptionsForm, "disable"); + + formStatusChange$.next("disabled"); + fixture.detectChanges(); + + expect(disable).toHaveBeenCalledWith({ emitEvent: false }); + + formStatusChange$.next("enabled"); + fixture.detectChanges(); + + expect(enable).toHaveBeenCalledWith({ emitEvent: false }); + }); + describe("Drag & Drop Functionality", () => { beforeEach(() => { // Prevent auto‑adding an empty URI by setting a non‑null initial value. diff --git a/libs/vault/src/cipher-form/components/autofill-options/autofill-options.component.ts b/libs/vault/src/cipher-form/components/autofill-options/autofill-options.component.ts index 7215b1d6c67..64e3d44a18c 100644 --- a/libs/vault/src/cipher-form/components/autofill-options/autofill-options.component.ts +++ b/libs/vault/src/cipher-form/components/autofill-options/autofill-options.component.ts @@ -140,9 +140,9 @@ export class AutofillOptionsComponent implements OnInit { this.cipherFormContainer.formStatusChange$.pipe(takeUntilDestroyed()).subscribe((status) => { // Disable adding new URIs when the cipher form is disabled if (status === "disabled") { - this.autofillOptionsForm.disable(); + this.autofillOptionsForm.disable({ emitEvent: false }); } else if (!this.isPartialEdit) { - this.autofillOptionsForm.enable(); + this.autofillOptionsForm.enable({ emitEvent: false }); } }); }