From 97a4326f22b62e4e7e9118c90d1e5bebcc5d49e5 Mon Sep 17 00:00:00 2001 From: matttdawson <89495499+matttdawson@users.noreply.github.com> Date: Thu, 23 May 2024 12:17:37 +1200 Subject: [PATCH 1/3] FEATURE: add colId to popover grid context --- src/contexts/GridPopoverContext.tsx | 2 ++ src/contexts/GridPopoverContextProvider.tsx | 3 +++ 2 files changed, 5 insertions(+) diff --git a/src/contexts/GridPopoverContext.tsx b/src/contexts/GridPopoverContext.tsx index 299b871a..e3eadb08 100644 --- a/src/contexts/GridPopoverContext.tsx +++ b/src/contexts/GridPopoverContext.tsx @@ -6,6 +6,7 @@ export interface GridPopoverContextType { anchorRef: RefObject; saving: boolean; setSaving: (saving: boolean) => void; + colId: string; field: keyof TData; value: any; data: TData; @@ -18,6 +19,7 @@ export const GridPopoverContext = createContext>({ anchorRef: { current: null }, saving: false, setSaving: () => {}, + colId: "", field: "", value: null, data: {} as GridBaseRow, diff --git a/src/contexts/GridPopoverContextProvider.tsx b/src/contexts/GridPopoverContextProvider.tsx index f7c1b0b9..28915a7a 100644 --- a/src/contexts/GridPopoverContextProvider.tsx +++ b/src/contexts/GridPopoverContextProvider.tsx @@ -26,7 +26,9 @@ export const GridPopoverContextProvider = ({ props, children }: PropsWithChildre multiEdit ? sortBy(getFilteredSelectedRows(), (row) => row.id !== props.data.id) : [props.data as GridBaseRow], [getFilteredSelectedRows, multiEdit, props.data], ); + const field = props.colDef?.field ?? ""; + const colId = props.colDef?.colId ?? field ?? ""; const updateValue = useCallback( async (saveFn: (selectedRows: any[]) => Promise, tabDirection: 1 | 0 | -1): Promise => { @@ -44,6 +46,7 @@ export const GridPopoverContextProvider = ({ props, children }: PropsWithChildre saving, setSaving, selectedRows, + colId, field, data: props.data, value: props.value, From aa6971a353490bd15f15f3f428a85e5a49890905 Mon Sep 17 00:00:00 2001 From: matttdawson <89495499+matttdawson@users.noreply.github.com> Date: Thu, 23 May 2024 12:30:47 +1200 Subject: [PATCH 2/3] feat: trigger release --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5ba2af00..55a3d85d 100644 --- a/README.md +++ b/README.md @@ -277,4 +277,4 @@ This will throw an exception if the row id is not found. ```tsx window.__stepAgGrid.grids[dataTestId].scrollRowIntoViewById("1000") -``` +``` \ No newline at end of file From 38f8074d6eb9120d355bca4ca94b41493f00f3dd Mon Sep 17 00:00:00 2001 From: matttdawson <89495499+matttdawson@users.noreply.github.com> Date: Thu, 23 May 2024 15:31:32 +1200 Subject: [PATCH 3/3] Fix autoresize --- src/components/Grid.tsx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/components/Grid.tsx b/src/components/Grid.tsx index f14d4cac..ef662b39 100644 --- a/src/components/Grid.tsx +++ b/src/components/Grid.tsx @@ -165,6 +165,8 @@ export const Grid = ({ const hasSetContentSizeEmpty = useRef(false); const needsAutoSize = useRef(true); + const lastFullResize = useRef(); + const setInitialContentSize = useCallback(() => { if (!gridDivRef.current?.clientWidth || rowData == null) { // Don't resize grids if they are offscreen as it doesn't work. @@ -193,8 +195,13 @@ export const Grid = ({ } } else if (gridRendered === "rows-visible") { if (!hasSetContentSize.current) { - hasSetContentSize.current = true; - params.onContentSize?.(result); + if (lastFullResize.current === result.width) { + hasSetContentSize.current = true; + params.onContentSize?.(result); + } else { + needsAutoSize.current = true; + } + lastFullResize.current = result.width; } } else { // It should be impossible to get here