summaryrefslogtreecommitdiff
path: root/components/data-table/data-table-view-options.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'components/data-table/data-table-view-options.tsx')
-rw-r--r--components/data-table/data-table-view-options.tsx12
1 files changed, 7 insertions, 5 deletions
diff --git a/components/data-table/data-table-view-options.tsx b/components/data-table/data-table-view-options.tsx
index 422e3065..b689adab 100644
--- a/components/data-table/data-table-view-options.tsx
+++ b/components/data-table/data-table-view-options.tsx
@@ -39,6 +39,7 @@ import {
} from "@/components/ui/sortable"
import { useTranslation } from '@/i18n/client'
import { useParams, usePathname } from "next/navigation";
+import deepEqual from "fast-deep-equal"
/**
@@ -70,6 +71,7 @@ export function DataTableViewOptions<TData>({
}: DataTableViewOptionsProps<TData>) {
const triggerRef = React.useRef<HTMLButtonElement>(null)
+
const params = useParams();
const lng = params?.lng as string;
const { t } = useTranslation(lng);
@@ -115,11 +117,11 @@ export function DataTableViewOptions<TData>({
const finalOrder = [...nonHideable, ...columnOrder]
// Now we set the table's official column order
- table.setColumnOrder(finalOrder)
-
- // Reset auto-size when column order changes
- resetAutoSize?.()
- }, [columnOrder, hideableCols, table, resetAutoSize])
+ if (!deepEqual(table.getState().columnOrder, finalOrder)) {
+ table.setColumnOrder(finalOrder)
+ resetAutoSize?.()
+ }
+ }, [columnOrder, hideableCols.join("|"), table, resetAutoSize])
return (