From 7f0aa0697aa0f4c5f014596afe90d4f17ada8317 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Tue, 3 Mar 2026 19:20:25 +0200 Subject: [PATCH] fix(spreadsheet): error due to duplicate unit IDs --- apps/client/src/widgets/type_widgets/Spreadsheet.tsx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/apps/client/src/widgets/type_widgets/Spreadsheet.tsx b/apps/client/src/widgets/type_widgets/Spreadsheet.tsx index 8965c6c94d..d8e6b93ed2 100644 --- a/apps/client/src/widgets/type_widgets/Spreadsheet.tsx +++ b/apps/client/src/widgets/type_widgets/Spreadsheet.tsx @@ -82,6 +82,12 @@ function usePersistence(note: FNote, noteContext: NoteContext | null | undefined const univerAPI = apiRef.current; if (!univerAPI) return undefined; + // Dispose the existing workbook. + const existingNotebook = univerAPI.getActiveWorkbook(); + if (existingNotebook) { + univerAPI.disposeUnit(existingNotebook.getId()); + } + let workbook: Partial = {}; if (newContent) { try {