summaryrefslogtreecommitdiff
path: root/components/data-table/data-table-grobal-filter.tsx
diff options
context:
space:
mode:
authordujinkim <dujin.kim@dtsolution.co.kr>2025-09-17 09:08:16 +0000
committerdujinkim <dujin.kim@dtsolution.co.kr>2025-09-17 09:08:16 +0000
commitf7117370b9cc0c7b96bd1eb23a1b9f5b16cc8ceb (patch)
tree4efb0a5ce420b44a402810fc19c35afc92ec5271 /components/data-table/data-table-grobal-filter.tsx
parentc54e2acaed641b7ae2c1a7304b08626f9ca973db (diff)
parent7433eea5b4bbc0899e255b88e1a7e91f26e9d95b (diff)
Merge branch 'dujinkim' of https://github.com/DTS-Development/SHI_EVCP into dujinkim
Diffstat (limited to 'components/data-table/data-table-grobal-filter.tsx')
-rw-r--r--components/data-table/data-table-grobal-filter.tsx15
1 files changed, 14 insertions, 1 deletions
diff --git a/components/data-table/data-table-grobal-filter.tsx b/components/data-table/data-table-grobal-filter.tsx
index fa0c809c..5714d92a 100644
--- a/components/data-table/data-table-grobal-filter.tsx
+++ b/components/data-table/data-table-grobal-filter.tsx
@@ -19,12 +19,25 @@ export function DataTableGlobalFilter() {
shallow: false,
})
+ // Page state to reset when search changes
+ const [, setPage] = useQueryState("page", {
+ parse: (str) => str ? parseInt(str) : 1,
+ serialize: (val) => val.toString(),
+ eq: (a, b) => a === b,
+ clearOnDefault: true,
+ shallow: false,
+ })
+
// Local tempValue to update instantly on user keystroke
const [tempValue, setTempValue] = React.useState(searchValue ?? "")
// Debounced callback that sets the URL param after `delay` ms
const debouncedSetSearch = useDebouncedCallback((value: string) => {
- if (value !== searchValue) setSearchValue(value.trim() === "" ? null : value);
+ if (value !== searchValue) {
+ // Reset page to 1 when search changes
+ void setPage(1);
+ setSearchValue(value.trim() === "" ? null : value);
+ }
}, 300)
// When user types, update local `tempValue` immediately,