Skip to content

Commit

Permalink
Add extra undefined check for table filters (#8008) (#8014)
Browse files Browse the repository at this point in the history
* 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 7d844e0)

Co-authored-by: Oliver <oliver.henry.walters@gmail.com>
  • Loading branch information
github-actions[bot] and SchrodingersGat authored Aug 27, 2024
1 parent edf02cd commit e89cfd4
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/frontend/src/tables/FilterSelectDrawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
);

Expand Down

0 comments on commit e89cfd4

Please sign in to comment.