Handle list auto size when vertical scroll appears
This commit is contained in:
parent
cf489d3934
commit
4eb90d20a2
1 changed files with 10 additions and 0 deletions
|
@ -10,6 +10,7 @@ import type {
|
||||||
NewColumnsLoadedEvent,
|
NewColumnsLoadedEvent,
|
||||||
GridReadyEvent,
|
GridReadyEvent,
|
||||||
GridSizeChangedEvent,
|
GridSizeChangedEvent,
|
||||||
|
ModelUpdatedEvent,
|
||||||
} from '@ag-grid-community/core';
|
} from '@ag-grid-community/core';
|
||||||
import type { AgGridReactProps } from '@ag-grid-community/react';
|
import type { AgGridReactProps } from '@ag-grid-community/react';
|
||||||
import { AgGridReact } from '@ag-grid-community/react';
|
import { AgGridReact } from '@ag-grid-community/react';
|
||||||
|
@ -418,6 +419,14 @@ export const VirtualTable = forwardRef(
|
||||||
[autoFitColumns, onGridSizeChanged],
|
[autoFitColumns, onGridSizeChanged],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const handleModelUpdated = useCallback(
|
||||||
|
(e: ModelUpdatedEvent) => {
|
||||||
|
if (!e?.api) return;
|
||||||
|
if (autoFitColumns) e.api?.sizeColumnsToFit?.();
|
||||||
|
},
|
||||||
|
[autoFitColumns],
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<TableWrapper
|
<TableWrapper
|
||||||
ref={deselectRef}
|
ref={deselectRef}
|
||||||
|
@ -447,6 +456,7 @@ export const VirtualTable = forwardRef(
|
||||||
onColumnMoved={handleColumnMoved}
|
onColumnMoved={handleColumnMoved}
|
||||||
onGridReady={handleGridReady}
|
onGridReady={handleGridReady}
|
||||||
onGridSizeChanged={handleGridSizeChanged}
|
onGridSizeChanged={handleGridSizeChanged}
|
||||||
|
onModelUpdated={handleModelUpdated}
|
||||||
onNewColumnsLoaded={handleNewColumnsLoaded}
|
onNewColumnsLoaded={handleNewColumnsLoaded}
|
||||||
/>
|
/>
|
||||||
</TableWrapper>
|
</TableWrapper>
|
||||||
|
|
Reference in a new issue