@linzjs/step-ag-grid 29.3.0 → 29.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2776,7 +2776,7 @@ const Grid = ({ 'data-testid': dataTestId, defaultPostSort = true, rowSelection
2776
2776
  const hasSetContentSize = useRef(false);
2777
2777
  const hasSetContentSizeEmpty = useRef(false);
2778
2778
  const needsAutoSize = useRef(true);
2779
- const lastFullResize = useRef();
2779
+ const requiresInitialSizeToFitRef = useRef(true);
2780
2780
  const autoSizeResultRef = useRef(null);
2781
2781
  const prevRowsVisibleRef = useRef(false);
2782
2782
  const setInitialContentSize = useCallback(() => {
@@ -2805,6 +2805,7 @@ const Grid = ({ 'data-testid': dataTestId, defaultPostSort = true, rowSelection
2805
2805
  autoSizeColumns({
2806
2806
  skipHeader,
2807
2807
  userSizedColIds: new Set(userSizedColIds.current.keys()),
2808
+ includeFlex: true,
2808
2809
  });
2809
2810
  // Auto-size failed retry later
2810
2811
  if (!autoSizeResult) {
@@ -2819,22 +2820,16 @@ const Grid = ({ 'data-testid': dataTestId, defaultPostSort = true, rowSelection
2819
2820
  // We don't do this callback if we have previously had row data, or have already called back for empty
2820
2821
  if (!hasSetContentSizeEmpty.current && !hasSetContentSize.current) {
2821
2822
  hasSetContentSizeEmpty.current = true;
2823
+ requiresInitialSizeToFitRef.current = true;
2822
2824
  params.onContentSize?.(autoSizeResult);
2823
2825
  }
2824
2826
  }
2825
2827
  else if (gridRendered === 'rows-visible') {
2826
2828
  // we have rows now so callback grid size
2827
2829
  if (!hasSetContentSize.current) {
2828
- // Only callback if grid size has settled
2829
- if (lastFullResize.current === autoSizeResult.width) {
2830
- hasSetContentSize.current = true;
2831
- params.onContentSize?.(autoSizeResult);
2832
- }
2833
- else {
2834
- // Need to retry callback when size has settelled
2835
- lastFullResize.current = autoSizeResult.width;
2836
- return;
2837
- }
2830
+ hasSetContentSize.current = true;
2831
+ requiresInitialSizeToFitRef.current = true;
2832
+ params.onContentSize?.(autoSizeResult);
2838
2833
  }
2839
2834
  }
2840
2835
  else {
@@ -2842,13 +2837,9 @@ const Grid = ({ 'data-testid': dataTestId, defaultPostSort = true, rowSelection
2842
2837
  console.error('Unknown value returned from hasGridRendered');
2843
2838
  }
2844
2839
  }
2845
- // 2. Now we size columns to fit the grid width
2846
- if (sizeColumns !== 'none') {
2847
- sizeColumnsToFit();
2848
- }
2849
2840
  setAutoSized(true);
2850
2841
  needsAutoSize.current = false;
2851
- }, [autoSizeColumns, gridRenderState, maxInitialWidth, params, rowData, sizeColumns, sizeColumnsToFit]);
2842
+ }, [autoSizeColumns, gridRenderState, maxInitialWidth, params, rowData, sizeColumns]);
2852
2843
  const lastOwnerDocumentRef = useRef();
2853
2844
  const wasVisibleRef = useRef(false);
2854
2845
  /**
@@ -3145,6 +3136,9 @@ const Grid = ({ 'data-testid': dataTestId, defaultPostSort = true, rowSelection
3145
3136
  * Resize columns to fit if required on window/container resize
3146
3137
  */
3147
3138
  const onGridResize = useCallback((event) => {
3139
+ if (!hasSetContentSizeEmpty.current && !hasSetContentSize.current) {
3140
+ return;
3141
+ }
3148
3142
  if (sizeColumns !== 'none') {
3149
3143
  // Flex columns can expand to fit after resize, but they cannot shrink less than use resized value
3150
3144
  // Double click column resize handle to reset this behaviour
@@ -3155,7 +3149,7 @@ const Grid = ({ 'data-testid': dataTestId, defaultPostSort = true, rowSelection
3155
3149
  maxWidth: w,
3156
3150
  })),
3157
3151
  ];
3158
- event.api.sizeColumnsToFit({ columnLimits });
3152
+ defer(() => event.api.sizeColumnsToFit({ columnLimits }));
3159
3153
  }
3160
3154
  }, [sizeColumns]);
3161
3155
  /**
@@ -3328,9 +3322,15 @@ const Grid = ({ 'data-testid': dataTestId, defaultPostSort = true, rowSelection
3328
3322
  ? {
3329
3323
  enableSelectionWithoutKeys: params.enableSelectionWithoutKeys ?? false,
3330
3324
  enableClickSelection: params.enableClickSelection ?? false,
3331
- mode: rowSelection == 'single' ? 'singleRow' : 'multiRow',
3325
+ mode: rowSelection === 'single' ? 'singleRow' : 'multiRow',
3326
+ }
3327
+ : undefined, onDisplayedColumnsChanged: () => {
3328
+ // This happens after an autosize event, if we don't wait for it size columns to fit doesn't work
3329
+ if (requiresInitialSizeToFitRef.current) {
3330
+ requiresInitialSizeToFitRef.current = false;
3331
+ sizeColumnsToFit();
3332
3332
  }
3333
- : undefined, rowHeight: rowHeight, animateRows: params.animateRows ?? false, rowClassRules: params.rowClassRules, getRowId: getRowId, onGridSizeChanged: onGridResize, suppressColumnVirtualisation: suppressColumnVirtualization, suppressClickEdit: true, onColumnVisible: setInitialContentSize, onRowDataUpdated: onRowDataChanged, onCellFocused: onCellFocused, onCellKeyDown: onCellKeyPress, onCellClicked: onCellClicked, onCellDoubleClicked: onCellDoubleClick, domLayout: params.domLayout, onColumnResized: onColumnResized, defaultColDef: defaultColDef, columnDefs: columnDefsAdjusted, selectionColumnDef: selectionColumnDef, rowData: rowData, postSortRows: params.onRowDragEnd || !defaultPostSort ? undefined : postSortRows, onModelUpdated: onModelUpdated, onGridReady: onGridReady, onSortChanged: ensureSelectedRowIsVisible, quickFilterParser: quickFilterParser, onSelectionChanged: synchroniseExternalStateToGridSelection, onColumnMoved: params.onColumnMoved, noRowsOverlayComponent: noRowsOverlayComponent, alwaysShowVerticalScroll: params.alwaysShowVerticalScroll, isExternalFilterPresent: isExternalFilterPresent, doesExternalFilterPass: doesExternalFilterPass, maintainColumnOrder: true, preventDefaultOnContextMenu: true, onCellContextMenu: gridContextMenu.cellContextMenu, rowDragText: params.rowDragText, onRowDragCancel: clearHighlightRowClasses, onRowDragMove: onRowDragMove, onRowDragEnd: onRowDragEnd, suppressCellFocus: params.suppressCellFocus, pinnedTopRowData: params.pinnedTopRowData, pinnedBottomRowData: params.pinnedBottomRowData, onRowClicked: params.onRowClicked, onRowDoubleClicked: params.onRowDoubleClicked, suppressStartEditOnTab: true }) })] }));
3333
+ }, rowHeight: rowHeight, animateRows: params.animateRows ?? false, rowClassRules: params.rowClassRules, getRowId: getRowId, onGridSizeChanged: onGridResize, suppressColumnVirtualisation: suppressColumnVirtualization, suppressClickEdit: true, onColumnVisible: setInitialContentSize, onRowDataUpdated: onRowDataChanged, onCellFocused: onCellFocused, onCellKeyDown: onCellKeyPress, onCellClicked: onCellClicked, onCellDoubleClicked: onCellDoubleClick, domLayout: params.domLayout, onColumnResized: onColumnResized, defaultColDef: defaultColDef, columnDefs: columnDefsAdjusted, selectionColumnDef: selectionColumnDef, rowData: rowData, postSortRows: params.onRowDragEnd || !defaultPostSort ? undefined : postSortRows, onModelUpdated: onModelUpdated, onGridReady: onGridReady, onSortChanged: ensureSelectedRowIsVisible, quickFilterParser: quickFilterParser, onSelectionChanged: synchroniseExternalStateToGridSelection, onColumnMoved: params.onColumnMoved, noRowsOverlayComponent: noRowsOverlayComponent, alwaysShowVerticalScroll: params.alwaysShowVerticalScroll, isExternalFilterPresent: isExternalFilterPresent, doesExternalFilterPass: doesExternalFilterPass, maintainColumnOrder: true, preventDefaultOnContextMenu: true, onCellContextMenu: gridContextMenu.cellContextMenu, rowDragText: params.rowDragText, onRowDragCancel: clearHighlightRowClasses, onRowDragMove: onRowDragMove, onRowDragEnd: onRowDragEnd, suppressCellFocus: params.suppressCellFocus, pinnedTopRowData: params.pinnedTopRowData, pinnedBottomRowData: params.pinnedBottomRowData, onRowClicked: params.onRowClicked, onRowDoubleClicked: params.onRowDoubleClicked, suppressStartEditOnTab: true }) })] }));
3334
3334
  };
3335
3335
  const quickFilterParser = (filterStr) => {
3336
3336
  // filter is exact matches exactly groups separated by commas