summaryrefslogtreecommitdiff
path: root/lib/docu-list-rule/combo-box-settings/table/combo-box-settings-table.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'lib/docu-list-rule/combo-box-settings/table/combo-box-settings-table.tsx')
-rw-r--r--lib/docu-list-rule/combo-box-settings/table/combo-box-settings-table.tsx25
1 files changed, 22 insertions, 3 deletions
diff --git a/lib/docu-list-rule/combo-box-settings/table/combo-box-settings-table.tsx b/lib/docu-list-rule/combo-box-settings/table/combo-box-settings-table.tsx
index 42ce1a19..8e469149 100644
--- a/lib/docu-list-rule/combo-box-settings/table/combo-box-settings-table.tsx
+++ b/lib/docu-list-rule/combo-box-settings/table/combo-box-settings-table.tsx
@@ -5,8 +5,8 @@ import { useDataTable } from "@/hooks/use-data-table"
import { DataTable } from "@/components/data-table/data-table"
import { DataTableAdvancedToolbar } from "@/components/data-table/data-table-advanced-toolbar"
import type { DataTableAdvancedFilterField } from "@/types/table"
-import { getColumns } from "./combo-box-settings-table-columns"
-import { ComboBoxOptionsDetailSheet } from "./combo-box-options-detail-sheet"
+import { getColumns } from "@/lib/docu-list-rule/combo-box-settings/table/combo-box-settings-table-columns"
+import { ComboBoxOptionsDetailSheet } from "@/lib/docu-list-rule/combo-box-settings/table/combo-box-options-detail-sheet"
import { codeGroups } from "@/db/schema/docu-list-rule"
interface ComboBoxSettingsTableProps {
@@ -61,11 +61,30 @@ export function ComboBoxSettingsTable({ promises }: ComboBoxSettingsTableProps)
},
],
},
- getRowId: (originalRow) => String(originalRow.groupId),
+ getRowId: (originalRow) => String(originalRow.id),
shallow: false,
clearOnDefault: true,
})
+ // 컴포넌트 마운트 후 그룹핑 설정
+ React.useEffect(() => {
+ if (rawData[0]?.data && table.getState().grouping.length === 0) {
+ table.setGrouping(["projectCode"])
+ }
+ }, [table, rawData])
+
+ // 정렬 시 펼쳐진 상태 유지
+ React.useEffect(() => {
+ const currentExpanded = table.getState().expanded
+ if (Object.keys(currentExpanded).length > 0) {
+ // 약간의 지연 후 현재 펼쳐진 상태를 다시 설정
+ const timer = setTimeout(() => {
+ table.setExpanded(currentExpanded)
+ }, 100)
+ return () => clearTimeout(timer)
+ }
+ }, [table.getState().sorting, table])
+
return (
<>
<DataTable table={table}>