Skip to content

Commit

Permalink
fix searching for multi partitions
Browse files Browse the repository at this point in the history
  • Loading branch information
dliu27 committed Dec 18, 2024
1 parent 910838e commit e1dc3f8
Showing 1 changed file with 17 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,20 @@ export const AssetPartitions = ({
.filter((s: AssetPartitionStatus) => DISPLAYED_STATUSES.includes(s)),
});

const [searchValue, setSearchValue] = useQueryPersistedState<string>({
queryKey: 'search',
defaults: {search: ''},
});
const [searchValues, setSearchValues] = useState<string[]>([]);
const updateSearchValue = (idx: number, value: string) => {
setSearchValues((prev) => {
const next = [...prev];

// add empty strings for missing indices
while (next.length <= idx) {
next.push('');
}

next[idx] = value;
return next;
});
};

// Determine which axis we will show at the top of the page, if any.
const timeDimensionIdx = selections.findIndex((s) => isTimeseriesDimension(s.dimension));
Expand Down Expand Up @@ -148,7 +158,7 @@ export const AssetPartitions = ({
const sortType = getSort(sortTypes, idx, selections[idx]!.dimension.type);

// Apply the search filter
const searchLower = searchValue.toLocaleLowerCase().trim();
const searchLower = searchValues?.[idx]?.toLocaleLowerCase().trim() || '';
const filteredKeys = allKeys.filter((key) => key.toLowerCase().includes(searchLower));

const getSelectionKeys = () =>
Expand Down Expand Up @@ -269,8 +279,8 @@ export const AssetPartitions = ({
<TextInput
fill
icon="search"
value={searchValue}
onChange={(e) => setSearchValue(e.target.value)}
value={searchValues[idx] || ''}
onChange={(e) => updateSearchValue(idx, e.target.value)}
placeholder="Filter by name…"
/>
</Box>
Expand Down

0 comments on commit e1dc3f8

Please sign in to comment.