From e6ff64734340a2c33e4b1f02e980aa35b9c37642 Mon Sep 17 00:00:00 2001 From: Nick Krantz <125900171+nick-livefront@users.noreply.github.com> Date: Fri, 4 Oct 2024 13:16:21 -0500 Subject: [PATCH] fix value update for match detections (#11417) --- .../autofill-options/uri-option.component.spec.ts | 11 +++++++++++ .../autofill-options/uri-option.component.ts | 4 ++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/libs/vault/src/cipher-form/components/autofill-options/uri-option.component.spec.ts b/libs/vault/src/cipher-form/components/autofill-options/uri-option.component.spec.ts index 673f7326c1..cf298b19ac 100644 --- a/libs/vault/src/cipher-form/components/autofill-options/uri-option.component.spec.ts +++ b/libs/vault/src/cipher-form/components/autofill-options/uri-option.component.spec.ts @@ -96,6 +96,17 @@ describe("UriOptionComponent", () => { expect(component["uriForm"].enabled).toBe(false); }); + it("should update form when `writeValue` is invoked", () => { + expect(component["uriForm"].value).toEqual({ uri: null, matchDetection: null }); + + component.writeValue({ uri: "example.com", matchDetection: UriMatchStrategy.Exact }); + + expect(component["uriForm"].value).toEqual({ + uri: "example.com", + matchDetection: UriMatchStrategy.Exact, + }); + }); + describe("match detection", () => { it("should hide the match detection select by default", () => { fixture.detectChanges(); diff --git a/libs/vault/src/cipher-form/components/autofill-options/uri-option.component.ts b/libs/vault/src/cipher-form/components/autofill-options/uri-option.component.ts index 26f59ba9c1..a7741ae1bc 100644 --- a/libs/vault/src/cipher-form/components/autofill-options/uri-option.component.ts +++ b/libs/vault/src/cipher-form/components/autofill-options/uri-option.component.ts @@ -149,12 +149,12 @@ export class UriOptionComponent implements ControlValueAccessor { } // NG_VALUE_ACCESSOR implementation - writeValue(value: any): void { + writeValue(value: { uri: string; matchDetection: UriMatchStrategySetting | null }): void { if (value) { this.uriForm.setValue( { uri: value.uri ?? "", - matchDetection: value.match ?? null, + matchDetection: value.matchDetection ?? null, }, { emitEvent: false }, );