diff --git a/semcore/data-table/src/components/DataTable/DataTable.tsx b/semcore/data-table/src/components/DataTable/DataTable.tsx index f651f9f15b..9091d5a31c 100644 --- a/semcore/data-table/src/components/DataTable/DataTable.tsx +++ b/semcore/data-table/src/components/DataTable/DataTable.tsx @@ -21,7 +21,7 @@ import type { DataTableType, ColumnGroupConfig, ColumnItemConfig, - DataRowItem, DTValue, + DataRowItem, } from './DataTable.types'; import scrollStyles from '../../style/scroll-shadows.shadow.css'; import { localizedMessages } from '../../translations/__intergalactic-dynamic-locales'; @@ -30,7 +30,6 @@ import type { BodyPropsInner } from '../Body/Body.types'; import { MergedColumnsCell, MergedRowsCell } from '../Body/MergedCells'; import type { DTRow } from '../Body/Row.types'; import type { DataTableColumnProps, DTColumn } from '../Head/Column.types'; -import type { DataTableGroupProps } from '../Head/Group.type'; import { Head } from '../Head/Head'; import type { DataTableHeadProps, HeadPropsInner } from '../Head/Head.types'; @@ -805,12 +804,14 @@ class DataTableRoot< this.changeFocusCell(-1, cellIndex === -1 ? 0 : cellIndex, 'up'); }; - handleContainerResizeEnd = () => { + handleContainerResizeEnd = (entries: ResizeObserverEntry[], observer: ResizeObserver) => { if (this.containerResizeEndTimeoutId) { clearTimeout(this.containerResizeEndTimeoutId); } this.containerResizeEndTimeoutId = setTimeout(this.calculateVerticalShadow, 0); + + this.asProps.onResize?.(entries, observer); }; render() { diff --git a/semcore/data-table/src/components/DataTable/DataTable.types.ts b/semcore/data-table/src/components/DataTable/DataTable.types.ts index f9a77cb468..4a6acd3c8c 100644 --- a/semcore/data-table/src/components/DataTable/DataTable.types.ts +++ b/semcore/data-table/src/components/DataTable/DataTable.types.ts @@ -191,6 +191,11 @@ export type DataTableProps< * Handle change expanded rows */ onExpandedRowsChange?: (expandedRows: Set) => void; + + /** + * Handling table container resizing. + */ + onResize?: ResizeObserverCallback; }; export type ColumnItemConfig = Intergalactic.InternalTypings.EfficientOmit< diff --git a/stories/components/data-table/advanced/examples/big_table_with_sticky_header.tsx b/stories/components/data-table/advanced/examples/big_table_with_sticky_header.tsx index e206ae0f8a..d77729e206 100644 --- a/stories/components/data-table/advanced/examples/big_table_with_sticky_header.tsx +++ b/stories/components/data-table/advanced/examples/big_table_with_sticky_header.tsx @@ -5,8 +5,9 @@ import { Hint } from '@semcore/ui/tooltip'; import React from 'react'; const Demo = () => { - return ( + const [_, forceUpdate] = React.useState(0); + return ( <> Some scrollable text before table @@ -24,6 +25,10 @@ const Demo = () => { withScrollBar: true, }} w='100%' + onResize={() => { + console.log('handle resize'); + forceUpdate((prev) => prev + 1); + }} columns={[ { name: 'group1',