chore: add check for user interaction in grid callbacks

This commit is contained in:
Matthew Russell
2023-08-09 17:48:29 +01:00
parent a6f31627f0
commit 0959b0da2b
2 changed files with 10 additions and 2 deletions
+9 -1
View File
@@ -39,8 +39,15 @@ export const useDataGridEvents = (
const onColumnChange = useMemo(
() =>
debounce(({ api, columnApi }: ColEvent) => {
debounce(({ api, columnApi, source }: ColEvent) => {
if (!api || !columnApi) return;
// only call back on user interactions
const permittedEvents = ['uiColumnMoved', 'uiColumnResized'];
if (!permittedEvents.includes(source)) {
return;
}
const columnState = columnApi.getColumnState();
callback({ columnState });
}, GRID_EVENT_DEBOUNCE_TIME),
@@ -60,6 +67,7 @@ export const useDataGridEvents = (
} else {
// ensure columns fit available space if no widths are set
columnApi.autoSizeAllColumns();
// api.sizeColumnsToFit();
}
if (state.filterModel) {
+1 -1
View File
@@ -235,7 +235,7 @@ export const PositionsTable = ({
},
},
{
headerName: t('Settlement asset'),
headerName: t('Asset'),
field: 'assetSymbol',
colId: 'asset',
cellRenderer: ({ data }: VegaICellRendererParams<Position>) => {