Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
chore(spreadsheet): mitigate cross-workspace formula contamination
Elian Dorandf78622d904f
diff --git a/apps/client/src/widgets/type_widgets/spreadsheet/persistence.tsx b/apps/client/src/widgets/type_widgets/spreadsheet/persistence.tsxindex ee7bad5d78..99fc85e484 100644--- a/apps/client/src/widgets/type_widgets/spreadsheet/persistence.tsx+++ b/apps/client/src/widgets/type_widgets/spreadsheet/persistence.tsx@@ -69,12 +69,7 @@ export default function usePersistence(note: FNote, noteContext: NoteContext | nfunction applyContent(univerAPI: FUniver, newContent: string) {const viewState = saveViewState(univerAPI);-- // Dispose the existing workbook.const existingWorkbook = univerAPI.getActiveWorkbook();- if (existingWorkbook) {- univerAPI.disposeUnit(existingWorkbook.getId());- }let workbookData: Partial<IWorkbookData> = {};if (newContent) {@@ -89,8 +84,14 @@ export default function usePersistence(note: FNote, noteContext: NoteContext | n}}+ // Create the new workbook BEFORE disposing the old one so the formula+ // engine transitions cleanly without a gap where stale state could leak.const workbook = univerAPI.createWorkbook(workbookData);+ if (existingWorkbook) {+ univerAPI.disposeUnit(existingWorkbook.getId());+ }+restoreViewState(workbook, viewState);if (changeListener.current) {