From 02b1cf005cf3e1df64183d20ba42930eb2767a9f Mon Sep 17 00:00:00 2001 From: dujinkim Date: Thu, 21 Aug 2025 06:57:36 +0000 Subject: (대표님, 최겸) 설계메뉴추가, 작업사항 업데이트 설계메뉴 - 문서관리 설계메뉴 - 벤더 데이터 gtc 메뉴 업데이트 정보시스템 - 메뉴리스트 및 정보 업데이트 파일 라우트 업데이트 엑셀임포트 개선 기본계약 개선 벤더 가입과정 변경 및 개선 벤더 기본정보 - pq 돌체 오류 수정 및 개선 벤더 로그인 과정 이메일 오류 수정 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/data-table/data-table-view-options.tsx | 25 ++++++++++++++--------- 1 file changed, 15 insertions(+), 10 deletions(-) (limited to 'components/data-table/data-table-view-options.tsx') diff --git a/components/data-table/data-table-view-options.tsx b/components/data-table/data-table-view-options.tsx index b689adab..592933f2 100644 --- a/components/data-table/data-table-view-options.tsx +++ b/components/data-table/data-table-view-options.tsx @@ -80,12 +80,14 @@ export function DataTableViewOptions({ const hideableCols = React.useMemo(() => { return table .getAllLeafColumns() - .filter((col) => col.getCanHide()) - }, [table]) + .filter((col) => col.getCanHide()) + }, [table.getAllLeafColumns().map(c => c.id).join(',')]) + // 2) local state for "columnOrder" (just the ID of hideable columns) // We'll reorder these with drag & drop + const isInitialized = React.useRef(false) const [columnOrder, setColumnOrder] = React.useState(() => hideableCols.map((c) => c.id) ) @@ -107,21 +109,24 @@ export function DataTableViewOptions({ // 4) After local state changes, reflect in tanstack table // - We do this in useEffect to avoid "update a different component" error React.useEffect(() => { - // Also consider "non-hideable" columns, if any, to keep them in original positions + if (!isInitialized.current) { + isInitialized.current = true + return + } + const nonHideable = table .getAllColumns() .filter((col) => !hideableCols.some((hc) => hc.id === col.id)) .map((c) => c.id) - // e.g. place nonHideable at the front, then our local hideable order const finalOrder = [...nonHideable, ...columnOrder] + const currentOrder = table.getState().columnOrder - // Now we set the table's official column order - if (!deepEqual(table.getState().columnOrder, finalOrder)) { - table.setColumnOrder(finalOrder) - resetAutoSize?.() - } - }, [columnOrder, hideableCols.join("|"), table, resetAutoSize]) + if (!deepEqual(currentOrder, finalOrder)) { + table.setColumnOrder(finalOrder) + resetAutoSize?.() + } + }, [columnOrder,hideableCols.map(c => c.id).join(','),resetAutoSize]) return ( -- cgit v1.2.3