From 7433eea5b4bbc0899e255b88e1a7e91f26e9d95b Mon Sep 17 00:00:00 2001
From: joonhoekim <26rote@gmail.com>
Date: Wed, 17 Sep 2025 18:04:10 +0900
Subject: (김준회) 자재그룹 선택기 오류수정, 공용사용을 위한 다이얼로그
 컴포넌트 구현, data-table 오류 수정
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 components/data-table/data-table-grobal-filter.tsx | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

(limited to 'components/data-table/data-table-grobal-filter.tsx')

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,
-- 
cgit v1.2.3

