@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.
@@ -2778,7 +2778,7 @@ const Grid = ({ 'data-testid': dataTestId, defaultPostSort = true, rowSelection
2778
2778
  const hasSetContentSize = React.useRef(false);
2779
2779
  const hasSetContentSizeEmpty = React.useRef(false);
2780
2780
  const needsAutoSize = React.useRef(true);
2781
- const lastFullResize = React.useRef();
2781
+ const requiresInitialSizeToFitRef = React.useRef(true);
2782
2782
  const autoSizeResultRef = React.useRef(null);
2783
2783
  const prevRowsVisibleRef = React.useRef(false);
2784
2784
  const setInitialContentSize = React.useCallback(() => {
@@ -2807,6 +2807,7 @@ const Grid = ({ 'data-testid': dataTestId, defaultPostSort = true, rowSelection
2807
2807
  autoSizeColumns({
2808
2808
  skipHeader,
2809
2809
  userSizedColIds: new Set(userSizedColIds.current.keys()),
2810
+ includeFlex: true,
2810
2811
  });
2811
2812
  // Auto-size failed retry later
2812
2813
  if (!autoSizeResult) {
@@ -2821,22 +2822,16 @@ const Grid = ({ 'data-testid': dataTestId, defaultPostSort = true, rowSelection
2821
2822
  // We don't do this callback if we have previously had row data, or have already called back for empty
2822
2823
  if (!hasSetContentSizeEmpty.current && !hasSetContentSize.current) {
2823
2824
  hasSetContentSizeEmpty.current = true;
2825
+ requiresInitialSizeToFitRef.current = true;
2824
2826
  params.onContentSize?.(autoSizeResult);
2825
2827
  }
2826
2828
  }
2827
2829
  else if (gridRendered === 'rows-visible') {
2828
2830
  // we have rows now so callback grid size
2829
2831
  if (!hasSetContentSize.current) {
2830
- // Only callback if grid size has settled
2831
- if (lastFullResize.current === autoSizeResult.width) {
2832
- hasSetContentSize.current = true;
2833
- params.onContentSize?.(autoSizeResult);
2834
- }
2835
- else {
2836
- // Need to retry callback when size has settelled
2837
- lastFullResize.current = autoSizeResult.width;
2838
- return;
2839
- }
2832
+ hasSetContentSize.current = true;
2833
+ requiresInitialSizeToFitRef.current = true;
2834
+ params.onContentSize?.(autoSizeResult);
2840
2835
  }
2841
2836
  }
2842
2837
  else {
@@ -2844,13 +2839,9 @@ const Grid = ({ 'data-testid': dataTestId, defaultPostSort = true, rowSelection
2844
2839
  console.error('Unknown value returned from hasGridRendered');
2845
2840
  }
2846
2841
  }
2847
- // 2. Now we size columns to fit the grid width
2848
- if (sizeColumns !== 'none') {
2849
- sizeColumnsToFit();
2850
- }
2851
2842
  setAutoSized(true);
2852
2843
  needsAutoSize.current = false;
2853
- }, [autoSizeColumns, gridRenderState, maxInitialWidth, params, rowData, sizeColumns, sizeColumnsToFit]);
2844
+ }, [autoSizeColumns, gridRenderState, maxInitialWidth, params, rowData, sizeColumns]);
2854
2845
  const lastOwnerDocumentRef = React.useRef();
2855
2846
  const wasVisibleRef = React.useRef(false);
2856
2847
  /**
@@ -3147,6 +3138,9 @@ const Grid = ({ 'data-testid': dataTestId, defaultPostSort = true, rowSelection
3147
3138
  * Resize columns to fit if required on window/container resize
3148
3139
  */
3149
3140
  const onGridResize = React.useCallback((event) => {
3141
+ if (!hasSetContentSizeEmpty.current && !hasSetContentSize.current) {
3142
+ return;
3143
+ }
3150
3144
  if (sizeColumns !== 'none') {
3151
3145
  // Flex columns can expand to fit after resize, but they cannot shrink less than use resized value
3152
3146
  // Double click column resize handle to reset this behaviour
@@ -3157,7 +3151,7 @@ const Grid = ({ 'data-testid': dataTestId, defaultPostSort = true, rowSelection
3157
3151
  maxWidth: w,
3158
3152
  })),
3159
3153
  ];
3160
- event.api.sizeColumnsToFit({ columnLimits });
3154
+ lodashEs.defer(() => event.api.sizeColumnsToFit({ columnLimits }));
3161
3155
  }
3162
3156
  }, [sizeColumns]);
3163
3157
  /**
@@ -3330,9 +3324,15 @@ const Grid = ({ 'data-testid': dataTestId, defaultPostSort = true, rowSelection
3330
3324
  ? {
3331
3325
  enableSelectionWithoutKeys: params.enableSelectionWithoutKeys ?? false,
3332
3326
  enableClickSelection: params.enableClickSelection ?? false,
3333
- mode: rowSelection == 'single' ? 'singleRow' : 'multiRow',
3327
+ mode: rowSelection === 'single' ? 'singleRow' : 'multiRow',
3328
+ }
3329
+ : undefined, onDisplayedColumnsChanged: () => {
3330
+ // This happens after an autosize event, if we don't wait for it size columns to fit doesn't work
3331
+ if (requiresInitialSizeToFitRef.current) {
3332
+ requiresInitialSizeToFitRef.current = false;
3333
+ sizeColumnsToFit();
3334
3334
  }
3335
- : 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 }) })] }));
3335
+ }, 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 }) })] }));
3336
3336
  };
3337
3337
  const quickFilterParser = (filterStr) => {
3338
3338
  // filter is exact matches exactly groups separated by commas