Skip to content

Commit

Permalink
Logic fix..
Browse files Browse the repository at this point in the history
- Do not return early, this is mistake!
- Correctly handle empty activeFilter state
  • Loading branch information
SchrodingersGat committed Aug 27, 2024
1 parent f963f6c commit 9713088
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/frontend/src/tables/FilterSelectDrawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,13 @@ function FilterAddGroup({
availableFilters: TableFilter[];
}) {
const filterOptions: TableFilterChoice[] = useMemo(() => {
if (!tableState?.activeFilters || tableState.activeFilters.length == 0) {
return [];
// 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) ?? [];
}
let activeFilterNames =
tableState.activeFilters?.map((flt) => flt.name) ?? [];

return (
availableFilters
Expand All @@ -86,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 9713088

Please sign in to comment.