@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.
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@linzjs/step-ag-grid",
3
3
  "repository": "github:linz/step-ag-grid.git",
4
4
  "license": "MIT",
5
- "version": "29.3.0",
5
+ "version": "29.3.1",
6
6
  "keywords": [
7
7
  "aggrid",
8
8
  "ag-grid",
@@ -83,7 +83,7 @@
83
83
  "@chromatic-com/storybook": "^4.1.1",
84
84
  "@linzjs/lui": "^23.11.1",
85
85
  "@linzjs/style": "^5.4.0",
86
- "@linzjs/windows": "^5.6.0",
86
+ "@linzjs/windows": "^5.7.0",
87
87
  "@rollup/plugin-commonjs": "^28.0.6",
88
88
  "@rollup/plugin-json": "^6.1.0",
89
89
  "@rollup/plugin-node-resolve": "^16.0.1",
@@ -26,7 +26,7 @@ import {
26
26
  } from 'ag-grid-community';
27
27
  import { AgGridReact } from 'ag-grid-react';
28
28
  import clsx from 'clsx';
29
- import { defer, difference, isEmpty, last, omit, xorBy } from 'lodash-es';
29
+ import { defer, delay, difference, isEmpty, last, omit, xorBy } from 'lodash-es';
30
30
  import { ReactElement, useCallback, useContext, useEffect, useMemo, useRef, useState } from 'react';
31
31
  import { useInterval } from 'usehooks-ts';
32
32
 
@@ -192,8 +192,7 @@ export const Grid = <TData extends GridBaseRow = GridBaseRow>({
192
192
  const hasSetContentSizeEmpty = useRef(false);
193
193
  const needsAutoSize = useRef(true);
194
194
 
195
- const lastFullResize = useRef<number>();
196
-
195
+ const requiresInitialSizeToFitRef = useRef(true);
197
196
  const autoSizeResultRef = useRef<AutoSizeColumnsResult | null>(null);
198
197
  const prevRowsVisibleRef = useRef(false);
199
198
  const setInitialContentSize = useCallback(() => {
@@ -225,6 +224,7 @@ export const Grid = <TData extends GridBaseRow = GridBaseRow>({
225
224
  autoSizeColumns({
226
225
  skipHeader,
227
226
  userSizedColIds: new Set(userSizedColIds.current.keys()),
227
+ includeFlex: true,
228
228
  });
229
229
  // Auto-size failed retry later
230
230
  if (!autoSizeResult) {
@@ -240,31 +240,32 @@ export const Grid = <TData extends GridBaseRow = GridBaseRow>({
240
240
  // We don't do this callback if we have previously had row data, or have already called back for empty
241
241
  if (!hasSetContentSizeEmpty.current && !hasSetContentSize.current) {
242
242
  hasSetContentSizeEmpty.current = true;
243
+ requiresInitialSizeToFitRef.current = true;
243
244
  params.onContentSize?.(autoSizeResult);
244
245
  }
245
246
  } else if (gridRendered === 'rows-visible') {
246
247
  // we have rows now so callback grid size
247
248
  if (!hasSetContentSize.current) {
248
- // Only callback if grid size has settled
249
- if (lastFullResize.current === autoSizeResult.width) {
250
- hasSetContentSize.current = true;
251
- params.onContentSize?.(autoSizeResult);
252
- } else {
253
- // Need to retry callback when size has settelled
254
- lastFullResize.current = autoSizeResult.width;
255
- return;
256
- }
249
+ hasSetContentSize.current = true;
250
+ requiresInitialSizeToFitRef.current = true;
251
+ params.onContentSize?.(autoSizeResult);
257
252
  }
258
253
  } else {
259
254
  // It should be impossible to get here
260
255
  console.error('Unknown value returned from hasGridRendered');
261
256
  }
262
- }
263
257
 
264
- // 2. Now we size columns to fit the grid width
265
- if (sizeColumns !== 'none') {
266
- sizeColumnsToFit();
258
+ // If there's no contentSize callback there'll be on onGridResize callback
259
+ // which is required to run sizeColumnsToFit.
260
+ // There's also the possibility that the panel was already the right size so didn't trigger onGridResize.
261
+ delay(() => {
262
+ if (requiresInitialSizeToFitRef.current) {
263
+ requiresInitialSizeToFitRef.current = false;
264
+ sizeColumnsToFit();
265
+ }
266
+ }, 50);
267
267
  }
268
+
268
269
  setAutoSized(true);
269
270
  needsAutoSize.current = false;
270
271
  }, [autoSizeColumns, gridRenderState, maxInitialWidth, params, rowData, sizeColumns, sizeColumnsToFit]);
@@ -625,7 +626,8 @@ export const Grid = <TData extends GridBaseRow = GridBaseRow>({
625
626
  }),
626
627
  ),
627
628
  ];
628
- event.api.sizeColumnsToFit({ columnLimits });
629
+ requiresInitialSizeToFitRef.current = false;
630
+ defer(() => event.api.sizeColumnsToFit({ columnLimits }));
629
631
  }
630
632
  },
631
633
  [sizeColumns],
@@ -12,7 +12,7 @@ const meta: Meta<typeof TestShowPanelResizingAgGrid> = {
12
12
  decorators: [
13
13
  (Story) => (
14
14
  <div>
15
- <PanelsContextProvider baseZIndex={500}>
15
+ <PanelsContextProvider baseZIndex={500} panelStateOptions={null}>
16
16
  <Story />
17
17
  </PanelsContextProvider>
18
18
  </div>