mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-19 15:33:12 +09:00
Fix clearing a live-but-uncommitted search re-committing the old value
commitFilter now reads the live overrides from a ref that setFilter updates synchronously, so committing within the same event that changed a filter no longer sees a stale render closure. antd's Input.Search fires onSearch (before onChange) when the clear button is clicked, so onSearch now commits the cleared state instead of closing the dropdown, which had re-committed the still-live typed value. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
2898fdf5d3
commit
40407e52d6
3 files changed
+29
-12
No files matched your search
@@ -43,12 +43,17 @@ export default function useColumnSearch<T>(
|
||||
setSelectedKeys(values);
|
||||
tableState.setFilter(columnKey, values.length ? values : null);
|
||||
}}
|
||||
onSearch={() => close()}
|
||||
onClear={() => {
|
||||
setSelectedKeys([]);
|
||||
tableState.setFilter(columnKey, null);
|
||||
// Clearing is a deliberate action, so write it to the URL right away.
|
||||
tableState.commitFilter(columnKey, null);
|
||||
onSearch={value => {
|
||||
if (value) {
|
||||
close();
|
||||
} else {
|
||||
// antd fires onSearch with an empty value when the clear (X) is clicked
|
||||
// (before onChange); commit the cleared state instead of closing, which
|
||||
// would re-commit the still-live typed value.
|
||||
setSelectedKeys([]);
|
||||
tableState.setFilter(columnKey, null);
|
||||
tableState.commitFilter(columnKey, null);
|
||||
}
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
|
||||
Reference in new issue
Block a user