Skip to content

Build your personal knowledge base with Trilium Notes

fix(spreadsheet): error due to duplicate unit IDs

Elian Doran7f0aa0697aa0
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<IWorkbookData> = {};
if (newContent) {
try {