From b6dc2e91c613eefe6c49ac09e2870025168b891b Mon Sep 17 00:00:00 2001 From: ChengWei Date: Sun, 25 Jan 2026 20:56:23 +0800 Subject: [PATCH] fix(users-table): handle empty search keyword gracefully - Reset URL sync state when search keyword is empty or whitespace - Keep pagination behavior consistent when searching with empty input --- frontend/src/components/users/users-table.jsx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/frontend/src/components/users/users-table.jsx b/frontend/src/components/users/users-table.jsx index 6d039f1..b68115e 100644 --- a/frontend/src/components/users/users-table.jsx +++ b/frontend/src/components/users/users-table.jsx @@ -585,12 +585,18 @@ export function UsersTable() { // Update search keyword state const handleSearchChange = React.useCallback((keyword) => { allowUrlSyncRef.current = true; + if (!keyword || !keyword.trim()) { + skipNextUrlUpdateRef.current = false; + } setQueryParams((prev) => ({ ...prev, keyword })); }, []); // Execute search and fetch users const handleSearch = React.useCallback((keyword) => { allowUrlSyncRef.current = true; + if (!keyword || !keyword.trim()) { + skipNextUrlUpdateRef.current = false; + } if (table.getState().pagination.pageIndex !== 0) { table.setPageIndex(0); } @@ -773,6 +779,7 @@ export function UsersTable() { requestAnimationFrame(() => { isHydratingFromUrlRef.current = false; skipNextUrlUpdateRef.current = true; + allowUrlSyncRef.current = true; }); } return;