@linzjs/step-ag-grid 29.3.0 → 29.3.1

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.
@@ -2,7 +2,7 @@ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
2
2
  import { LuiMiniSpinner, LuiStatusSpinner, LuiIcon, LuiButtonGroup, LuiButton, LuiCheckboxInput } from '@linzjs/lui';
3
3
  import { ModuleRegistry, AllCommunityModule } from 'ag-grid-community';
4
4
  import { AgGridReact } from 'ag-grid-react';
5
- import { negate, isEmpty, findIndex, defer, debounce as debounce$1, xorBy, last, difference, omit, sortBy, delay, partition, compact, pick, groupBy, fromPairs, toPairs, isEqual, pull, filter, sumBy, remove, flatten, castArray } from 'lodash-es';
5
+ import { negate, isEmpty, findIndex, defer, debounce as debounce$1, delay, xorBy, last, difference, omit, sortBy, partition, compact, pick, groupBy, fromPairs, toPairs, isEqual, pull, filter, sumBy, remove, flatten, castArray } from 'lodash-es';
6
6
  import React, { useRef, useLayoutEffect, useEffect, createContext, useContext, useState, useMemo, memo, forwardRef, useCallback, useReducer, cloneElement, useImperativeHandle, Fragment as Fragment$1, useId } from 'react';
7
7
  import { unstable_batchedUpdates, flushSync, createPortal } from 'react-dom';
8
8
 
@@ -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,32 +2820,31 @@ 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 {
2841
2836
  // It should be impossible to get here
2842
2837
  console.error('Unknown value returned from hasGridRendered');
2843
2838
  }
2844
- }
2845
- // 2. Now we size columns to fit the grid width
2846
- if (sizeColumns !== 'none') {
2847
- sizeColumnsToFit();
2839
+ // If there's no contentSize callback there'll be on onGridResize callback
2840
+ // which is required to run sizeColumnsToFit.
2841
+ // There's also the possibility that the panel was already the right size so didn't trigger onGridResize.
2842
+ delay(() => {
2843
+ if (requiresInitialSizeToFitRef.current) {
2844
+ requiresInitialSizeToFitRef.current = false;
2845
+ sizeColumnsToFit();
2846
+ }
2847
+ }, 50);
2848
2848
  }
2849
2849
  setAutoSized(true);
2850
2850
  needsAutoSize.current = false;
@@ -3155,7 +3155,8 @@ const Grid = ({ 'data-testid': dataTestId, defaultPostSort = true, rowSelection
3155
3155
  maxWidth: w,
3156
3156
  })),
3157
3157
  ];
3158
- event.api.sizeColumnsToFit({ columnLimits });
3158
+ requiresInitialSizeToFitRef.current = false;
3159
+ defer(() => event.api.sizeColumnsToFit({ columnLimits }));
3159
3160
  }
3160
3161
  }, [sizeColumns]);
3161
3162
  /**