From 60e97a4968b379d4916b5f085ea0237a10a28812 Mon Sep 17 00:00:00 2001 From: Jason Ng Date: Fri, 20 Feb 2026 16:47:44 -0500 Subject: [PATCH] [PM-32341] use an initial cache value in default cipher form (#19091) * update default cipher form cache with initial cache value --- .../services/default-cipher-form-cache.service.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/libs/vault/src/cipher-form/services/default-cipher-form-cache.service.ts b/libs/vault/src/cipher-form/services/default-cipher-form-cache.service.ts index d525dcd9afa..f83c2bbb15b 100644 --- a/libs/vault/src/cipher-form/services/default-cipher-form-cache.service.ts +++ b/libs/vault/src/cipher-form/services/default-cipher-form-cache.service.ts @@ -18,6 +18,12 @@ export class CipherFormCacheService { */ initializedWithValue: boolean; + /** + * The cipher form will overwrite the cache from various components when initialized + * To prevent this, we store the initial value of the cache when the service is initialized + */ + initialCacheValue: CipherView | null; + private cipherCache = this.viewCacheService.signal({ key: CIPHER_FORM_CACHE_KEY, initialValue: null, @@ -26,6 +32,7 @@ export class CipherFormCacheService { constructor() { this.initializedWithValue = !!this.cipherCache(); + this.initialCacheValue = this.cipherCache(); } /** @@ -42,13 +49,14 @@ export class CipherFormCacheService { * Returns the cached CipherView when available. */ getCachedCipherView(): CipherView | null { - return this.cipherCache(); + return this.initialCacheValue; } /** * Clear the cached CipherView. */ clearCache(): void { + this.initialCacheValue = null; this.cipherCache.set(null); } }