From e89cfd4958dadf76240ad88430ebff97217c30d7 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 28 Aug 2024 09:34:26 +1000 Subject: [PATCH] Add extra undefined check for table filters (#8008) (#8014) * Add extra undefined check for table filters * Logic fix.. - Do not return early, this is mistake! - Correctly handle empty activeFilter state (cherry picked from commit 7d844e02be7af94a0e003113f0acaf448f2ec7bc) Co-authored-by: Oliver --- src/frontend/src/tables/FilterSelectDrawer.tsx | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/frontend/src/tables/FilterSelectDrawer.tsx b/src/frontend/src/tables/FilterSelectDrawer.tsx index cbe33feae9..a9a1f97a3c 100644 --- a/src/frontend/src/tables/FilterSelectDrawer.tsx +++ b/src/frontend/src/tables/FilterSelectDrawer.tsx @@ -65,8 +65,13 @@ function FilterAddGroup({ availableFilters: TableFilter[]; }) { const filterOptions: TableFilterChoice[] = useMemo(() => { - let activeFilterNames = - tableState.activeFilters?.map((flt) => flt.name) ?? []; + // List of filter names which are already active on this table + let activeFilterNames: string[] = []; + + if (tableState.activeFilters && tableState.activeFilters.length > 0) { + activeFilterNames = + tableState.activeFilters?.map((flt) => flt.name) ?? []; + } return ( availableFilters @@ -83,7 +88,7 @@ function FilterAddGroup({ const valueOptions: TableFilterChoice[] = useMemo(() => { // Find the matching filter - let filter: TableFilter | undefined = availableFilters.find( + let filter: TableFilter | undefined = availableFilters?.find( (flt) => flt.name === selectedFilter );