From 8407ae8cb467479935bcbae46a71e835663a8e0b Mon Sep 17 00:00:00 2001 From: Florent MILLOT <75525996+flomillot@users.noreply.github.com> Date: Tue, 19 May 2026 13:08:07 +0200 Subject: [PATCH] Fix spreadsheet showing empty rows after unrealizing an aliased node Spreadsheet rowData was pushed imperatively via setGridOption inside a useEffect gated by an isGridReady flag that was never reset when the grid unmounted. After unrealizing a node and navigating back to an aliased node, EquipmentTable remounted with a fresh AG Grid instance but isGridReady stayed true, so onGridReady did not trigger a re-render and the rowData effect ran once before the grid API was ready, ending as a no-op. With aliased nodes no fetch occurs, so rowData was never pushed again and the grid showed "No data". Pass rowData as a prop to CustomAGGrid so AG Grid keeps it in sync via its own render cycle, removing the race entirely. Also reset isGridReady when disabled flips to true so sort and filter effects re-apply on remount. Signed-off-by: Florent MILLOT <75525996+flomillot@users.noreply.github.com> --- .../spreadsheet-content/equipment-table.tsx | 1 + .../spreadsheet-content/spreadsheet-content.tsx | 14 ++++++++------ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/components/spreadsheet-view/spreadsheet/spreadsheet-content/equipment-table.tsx b/src/components/spreadsheet-view/spreadsheet/spreadsheet-content/equipment-table.tsx index d2f62c6ab2..4526296ef7 100644 --- a/src/components/spreadsheet-view/spreadsheet/spreadsheet-content/equipment-table.tsx +++ b/src/components/spreadsheet-view/spreadsheet/spreadsheet-content/equipment-table.tsx @@ -138,6 +138,7 @@ export const EquipmentTable: FunctionComponent = ({ <> state.spreadsheetNetwork.nodesIds); const { fetchNodesEquipmentData } = useFetchEquipment(); + // Reset isGridReady when the grid is unmounted (disabled=true), so a fresh + // false → true transition on remount re-triggers effects depending on it. + useEffect(() => { + if (disabled) { + setIsGridReady(false); + } + }, [disabled]); + // Initial data loading for this type when the tab is opened useEffect(() => { if (active && nodesIds.length > 0 && !equipments.isInitialized && !equipments.isFetching) { @@ -172,12 +180,6 @@ export const SpreadsheetContent = memo( ); }, [equipments, currentNode.id, nodeAliases]); - useEffect(() => { - if (gridRef.current?.api) { - gridRef.current.api.setGridOption('rowData', transformedRowData); - } - }, [transformedRowData, gridRef, isGridReady]); - const filters = useSelector((state) => getColumnFiltersFromState(state, TableType.Spreadsheet, tableDefinition?.uuid) );