From bea3aa8b555e5ec40fbe96863fdf75296b28a5ce Mon Sep 17 00:00:00 2001 From: Laurent Nguyen Date: Fri, 21 Jun 2024 12:05:50 +0200 Subject: [PATCH] Accumulate properties rather than replace for column definitions --- .../Tabs/DocumentsTabV2/DocumentsTabV2.tsx | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/Explorer/Tabs/DocumentsTabV2/DocumentsTabV2.tsx b/src/Explorer/Tabs/DocumentsTabV2/DocumentsTabV2.tsx index 47219274b..f13622061 100644 --- a/src/Explorer/Tabs/DocumentsTabV2/DocumentsTabV2.tsx +++ b/src/Explorer/Tabs/DocumentsTabV2/DocumentsTabV2.tsx @@ -1246,9 +1246,18 @@ export const DocumentsTabComponent: React.FunctionComponent { - // TODO Add fields rather than replace - setColumnDefinitions(extractColumnDefinitionsFromDocument(document)); + const currentIds = new Set(columnDefinitions.map((columnDefinition) => columnDefinition.id)); + extractColumnDefinitionsFromDocument(document).forEach((columnDefinition) => { + if (!currentIds.has(columnDefinition.id)) { + columnDefinitions.push(columnDefinition); + } + }); + setColumnDefinitions([...columnDefinitions]); }; /** @@ -1359,6 +1368,7 @@ export const DocumentsTabComponent: React.FunctionComponent resizeObserver.disconnect(); // clean up }, []); + // Column definition is a map to garantee uniqueness const [columnDefinitions, setColumnDefinitions] = useState(() => extractColumnDefinitionsFromDocument({ id: "id",