@linzjs/step-ag-grid 21.1.0 → 21.1.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.
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": "21.1.0",
5
+ "version": "21.1.2",
6
6
  "keywords": [
7
7
  "aggrid",
8
8
  "ag-grid",
@@ -165,6 +165,8 @@ export const Grid = ({
165
165
  const hasSetContentSizeEmpty = useRef(false);
166
166
  const needsAutoSize = useRef(true);
167
167
 
168
+ const lastFullResize = useRef<number>();
169
+
168
170
  const setInitialContentSize = useCallback(() => {
169
171
  if (!gridDivRef.current?.clientWidth || rowData == null) {
170
172
  // Don't resize grids if they are offscreen as it doesn't work.
@@ -193,8 +195,13 @@ export const Grid = ({
193
195
  }
194
196
  } else if (gridRendered === "rows-visible") {
195
197
  if (!hasSetContentSize.current) {
196
- hasSetContentSize.current = true;
197
- params.onContentSize?.(result);
198
+ if (lastFullResize.current === result.width) {
199
+ hasSetContentSize.current = true;
200
+ params.onContentSize?.(result);
201
+ } else {
202
+ needsAutoSize.current = true;
203
+ }
204
+ lastFullResize.current = result.width;
198
205
  }
199
206
  } else {
200
207
  // It should be impossible to get here
@@ -1,7 +1,12 @@
1
1
  import { LuiStatusSpinner } from "@linzjs/lui";
2
+ import { ForwardedRef, forwardRef } from "react";
2
3
 
3
- const GridLoadingOverlayComponent = (props: { headerRowHeight: number }) => (
4
+ const GridLoadingOverlayComponentFr = (
5
+ props: { headerRowHeight: number },
6
+ externalRef: ForwardedRef<HTMLDivElement>,
7
+ ) => (
4
8
  <div
9
+ ref={externalRef}
5
10
  style={{
6
11
  left: 0,
7
12
  top: 0,
@@ -19,6 +24,8 @@ const GridLoadingOverlayComponent = (props: { headerRowHeight: number }) => (
19
24
  </div>
20
25
  );
21
26
 
27
+ const GridLoadingOverlayComponent = forwardRef(GridLoadingOverlayComponentFr);
28
+
22
29
  export interface GridNoRowsOverlayProps {
23
30
  loading: boolean;
24
31
  rowCount: number | undefined | null;
@@ -28,10 +35,17 @@ export interface GridNoRowsOverlayProps {
28
35
  headerRowHeight: number;
29
36
  }
30
37
 
31
- export const GridNoRowsOverlay = (props: GridNoRowsOverlayProps) => {
32
- if (props.loading) return <GridLoadingOverlayComponent headerRowHeight={props.headerRowHeight} />;
33
- if (props.rowCount === 0) return <div>{props.noRowsOverlayText ?? "There are currently no rows"}</div>;
34
- if (props.filteredRowCount === 0)
35
- return <div>{props.noRowsMatchingOverlayText ?? "All rows have been filtered"}</div>;
36
- return <span />;
38
+ export const GridNoRowsOverlayFr = (props: GridNoRowsOverlayProps, externalRef: ForwardedRef<HTMLDivElement>) => {
39
+ if (props.loading) {
40
+ return <GridLoadingOverlayComponent ref={externalRef} headerRowHeight={props.headerRowHeight} />;
41
+ }
42
+ if (props.rowCount === 0) {
43
+ return <div ref={externalRef}>{props.noRowsOverlayText ?? "There are currently no rows"}</div>;
44
+ }
45
+ if (props.filteredRowCount === 0) {
46
+ return <div ref={externalRef}>{props.noRowsMatchingOverlayText ?? "All rows have been filtered"}</div>;
47
+ }
48
+ return <div ref={externalRef} />;
37
49
  };
50
+
51
+ export const GridNoRowsOverlay = forwardRef(GridNoRowsOverlayFr);