From def3863d587c5eed664c74293625904564705609 Mon Sep 17 00:00:00 2001 From: Nate Kelley Date: Wed, 19 Feb 2025 22:26:53 -0700 Subject: [PATCH] onColumnResize update --- .../ui/table/AppDataGrid/AppDataGrid.tsx | 45 ++++++++++--------- .../DashboardContainerHeaderButtons.tsx | 4 +- web/tsconfig.json | 2 +- 3 files changed, 27 insertions(+), 24 deletions(-) diff --git a/web/src/components/ui/table/AppDataGrid/AppDataGrid.tsx b/web/src/components/ui/table/AppDataGrid/AppDataGrid.tsx index cdfc60dfa..d8ed9aa76 100644 --- a/web/src/components/ui/table/AppDataGrid/AppDataGrid.tsx +++ b/web/src/components/ui/table/AppDataGrid/AppDataGrid.tsx @@ -1,8 +1,9 @@ 'use client'; -import DataGrid from 'react-data-grid'; +import { DataGrid } from 'react-data-grid'; import type { Column, + CalculatedColumn, CopyEvent, RenderCellProps, RenderHeaderCellProps, @@ -204,27 +205,30 @@ export const AppDataGrid: React.FC = React.memo( } }); - const onColumnResize = useMemoizedFn((index: number, size: number) => { - const newSizes = columns.reduce>((acc, column, i) => { - if (!column.key) return acc; + const onColumnResize = useMemoizedFn( + (column: CalculatedColumn, width: number) => { + const index = columns.findIndex((c) => c.key === column.key); + const newSizes = columns.reduce>((acc, column, i) => { + if (!column.key) return acc; - acc[column.key] = i === index ? round(size) : (column.width as number); - return acc; - }, {}); - const columnArray = columns - .map((column) => ({ - key: column.key, - size: newSizes[column.key] - })) - .sort( - (a, b) => - columnsOrder.indexOf(columns.findIndex((c) => c.key === a.key)) - - columnsOrder.indexOf(columns.findIndex((c) => c.key === b.key)) - ); + acc[column.key] = i === index ? round(width) : (column.width as number); + return acc; + }, {}); + const columnArray = columns + .map((column) => ({ + key: column.key, + size: newSizes[column.key] + })) + .sort( + (a, b) => + columnsOrder.indexOf(columns.findIndex((c) => c.key === a.key)) - + columnsOrder.indexOf(columns.findIndex((c) => c.key === b.key)) + ); - onResizeColumnsDebounce(columnArray); - onColumnResizeDebounce(); - }); + onResizeColumnsDebounce(columnArray); + onColumnResizeDebounce(); + } + ); const { run: onResizeColumnsDebounce } = useDebounceFn( (columnArray: { key: string; size: number }[]) => { @@ -356,6 +360,7 @@ export const AppDataGrid: React.FC = React.memo( enableVirtualization={rows.length > 60} onCopy={handleCopy} onColumnResize={onColumnResize} + // onColumnResize={onColumnResize} onColumnsReorder={onColumnsReorder} defaultColumnOptions={DEFAULT_COLUMN_WIDTH} direction={'ltr'} diff --git a/web/src/layouts/ChatLayout/FileContainer/FileContainerHeader/DashboardContainerHeaderButtons.tsx b/web/src/layouts/ChatLayout/FileContainer/FileContainerHeader/DashboardContainerHeaderButtons.tsx index d963aef30..7c3db68ae 100644 --- a/web/src/layouts/ChatLayout/FileContainer/FileContainerHeader/DashboardContainerHeaderButtons.tsx +++ b/web/src/layouts/ChatLayout/FileContainer/FileContainerHeader/DashboardContainerHeaderButtons.tsx @@ -6,9 +6,7 @@ import { SaveDashboardToCollectionButton } from '@/components/features/Buttons/S import { HideButtonContainer } from './HideButtonContainer'; import { useChatLayoutContextSelector } from '../../ChatLayoutContext'; import { CreateChatButton } from './CreateChatButtont'; -import { ShareDashboardButton } from '../../../../components/features/Buttons/ShareDashboardButton'; -import { BackButton } from '@/components/ui/buttons/BackButton'; -import { FileIndeterminateLoader as Testing123 } from '@/components/features'; +import { ShareDashboardButton } from '@/components/features/Buttons/ShareDashboardButton'; import { Button, Dropdown } from 'antd'; import { AppMaterialIcons } from '@/components/ui'; import { MenuProps } from 'antd/lib'; diff --git a/web/tsconfig.json b/web/tsconfig.json index 4e52b4daa..9c121b0bf 100644 --- a/web/tsconfig.json +++ b/web/tsconfig.json @@ -21,7 +21,7 @@ "paths": { "@/*": ["./src/*"], "@utils/*": ["./src/utils/*"], - "@/components/features/*": ["./src/app/app/_components/*"], + "@components/*": ["./src/components/*"], "@layouts/*": ["./src/layouts/*"], "@controllers/*": ["./src/controllers/*"], "@chatLayout/*": ["./src/layouts/ChatLayout/*"]