mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-19 07:33:12 +09:00
Fix commit filter logic for empty search strings
This commit is contained in:
2 files changed
+8
-23
No files matched your search
@@ -136,15 +136,12 @@ export function useUserFilter(
|
||||
: {};
|
||||
|
||||
// Update the live filter as the user types/toggles; the URL is only written when the
|
||||
// dropdown closes (see onOpenChange), or immediately when `commit` is set (e.g. clear).
|
||||
function update(next: Partial<UserFilter>, commit = false) {
|
||||
// dropdown closes (see onOpenChange) or when enter is pressed (see onPressEnter)
|
||||
function update(next: Partial<UserFilter>) {
|
||||
const encoded = encodeFilter({ ...filter, ...next });
|
||||
const values = encoded === "{}" ? null : [encoded];
|
||||
setSelectedKeys(values ?? []);
|
||||
tableState.setFilter(columnKey, values);
|
||||
if (commit) {
|
||||
tableState.commitFilter(columnKey, values);
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
@@ -155,13 +152,9 @@ export function useUserFilter(
|
||||
placeholder="Search username"
|
||||
value={filter.search}
|
||||
allowClear
|
||||
onSearch={value => {
|
||||
if (value) {
|
||||
close();
|
||||
} else {
|
||||
// Clear (X) fires onSearch with an empty value before onChange.
|
||||
update({ search: undefined }, true);
|
||||
}
|
||||
onPressEnter={e => {
|
||||
close();
|
||||
tableState.commitFilter(columnKey);
|
||||
}}
|
||||
onChange={(e) => update({ search: e.target.value !== "" ? e.target.value : undefined })}
|
||||
/>
|
||||
|
||||
Reference in new issue
Block a user