From ffdd9507ff9b8d4480885fa872a18cfaa073f776 Mon Sep 17 00:00:00 2001 From: addison Date: Thu, 14 Apr 2022 12:41:43 -0400 Subject: [PATCH] [bug] Null check lists when changing the vault filter Sometimes when changing an organization fault filter the system can end up in a postion where the filter modifier selected isn't valid for the newly selected organization. The clearest example of this are collections, since changing any org filter with a collection already selected will make that collection selection invalid. Because of this, when an organization filter is selected we check to make sure modifiers are still valid. If they aren't we clear them. This isn't working if a list is checked and this list is null. An error throws and the filter doesn't change. This commit adds a null check to keep things moving. --- angular/src/modules/vault-filter/vault-filter.component.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/angular/src/modules/vault-filter/vault-filter.component.ts b/angular/src/modules/vault-filter/vault-filter.component.ts index 6df55393..4fbda760 100644 --- a/angular/src/modules/vault-filter/vault-filter.component.ts +++ b/angular/src/modules/vault-filter/vault-filter.component.ts @@ -89,7 +89,10 @@ export class VaultFilterComponent implements OnInit { } protected pruneInvalidFolderSelection(filter: VaultFilter): VaultFilter { - if (filter.selectedFolder && !this.folders.hasId(filter.selectedFolderId)) { + if ( + filter.selectedFolder && + (this.folders == null || !this.folders.hasId(filter.selectedFolderId)) + ) { filter.selectedFolder = false; filter.selectedFolderId = null; } @@ -99,7 +102,7 @@ export class VaultFilterComponent implements OnInit { protected pruneInvalidCollectionSelection(filter: VaultFilter): VaultFilter { if ( filter.selectedCollectionId != null && - !this.collections.hasId(filter.selectedCollectionId) + (this.collections == null || !this.collections.hasId(filter.selectedCollectionId)) ) { filter.selectedCollectionId = null; }