Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ui] fix searching for multi partitions #26580

Merged
merged 2 commits into from
Dec 20, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading