diff --git a/apps/desktop/src/app/vault/vault.component.ts b/apps/desktop/src/app/vault/vault.component.ts index a3c606c29d4..f3f8c520a76 100644 --- a/apps/desktop/src/app/vault/vault.component.ts +++ b/apps/desktop/src/app/vault/vault.component.ts @@ -397,7 +397,7 @@ export class VaultComponent implements OnInit, OnDestroy { this.addType = type; this.action = "add"; this.cipherId = null; - this.updateCollectionProperties(); + this.prefillNewCipherFromFilter(); this.go(); } @@ -747,19 +747,21 @@ export class VaultComponent implements OnInit, OnDestroy { }); } - private updateCollectionProperties() { - if (this.collectionId != null) { - const collection = this.vaultFilterComponent.collections?.fullList?.filter( - (c) => c.id === this.collectionId + private prefillNewCipherFromFilter() { + if (this.activeFilter.selectedCollectionId != null) { + const collection = this.vaultFilterComponent.collections.fullList.filter( + (c) => c.id === this.activeFilter.selectedCollectionId ); - if (collection != null && collection.length > 0) { + if (collection.length > 0) { this.addOrganizationId = collection[0].organizationId; - this.addCollectionIds = [this.collectionId]; - return; + this.addCollectionIds = [this.activeFilter.selectedCollectionId]; } + } else if (this.activeFilter.selectedOrganizationId) { + this.addOrganizationId = this.activeFilter.selectedOrganizationId; + } + if (this.activeFilter.selectedFolderId && this.activeFilter.selectedFolder) { + this.folderId = this.activeFilter.selectedFolderId; } - this.addOrganizationId = null; - this.addCollectionIds = null; } private async canNavigateAway(action: string, cipher?: CipherView) {