diff --git a/apps/web/src/app/vault/individual-vault/vault.component.ts b/apps/web/src/app/vault/individual-vault/vault.component.ts index 5b68b3fbc2..8c1d08b269 100644 --- a/apps/web/src/app/vault/individual-vault/vault.component.ts +++ b/apps/web/src/app/vault/individual-vault/vault.component.ts @@ -779,16 +779,26 @@ export class VaultComponent implements OnInit, OnDestroy { null, cipherType, ); + const collectionId = + this.activeFilter.collectionId !== "AllCollections" && this.activeFilter.collectionId != null + ? this.activeFilter.collectionId + : null; + let organizationId = + this.activeFilter.organizationId !== "MyVault" && this.activeFilter.organizationId != null + ? this.activeFilter.organizationId + : null; + // Attempt to get the organization ID from the collection if present + if (collectionId) { + const organizationIdFromCollection = ( + await firstValueFrom(this.vaultFilterService.filteredCollections$) + ).find((c) => c.id === this.activeFilter.collectionId)?.organizationId; + if (organizationIdFromCollection) { + organizationId = organizationIdFromCollection; + } + } cipherFormConfig.initialValues = { - organizationId: - this.activeFilter.organizationId !== "MyVault" && this.activeFilter.organizationId != null - ? (this.activeFilter.organizationId as OrganizationId) - : null, - collectionIds: - this.activeFilter.collectionId !== "AllCollections" && - this.activeFilter.collectionId != null - ? [this.activeFilter.collectionId as CollectionId] - : [], + organizationId: organizationId as OrganizationId, + collectionIds: [collectionId as CollectionId], folderId: this.activeFilter.folderId, };