Skip to content

Build your own AI office with Univer Office SDK. Bring editing, calculation, collaboration, and file processing into your product for people and AI agents. Built on an extensible open-source core.

fix(sheets-formula-ui): handle potential null reference for currentDoc in useRefactorEffect (#5932)

白熱dbfe4e6a8bd7
diff --git a/packages/sheets-formula-ui/src/views/formula-editor/hooks/use-refactor-effect.ts b/packages/sheets-formula-ui/src/views/formula-editor/hooks/use-refactor-effect.ts
index c1dae28d1c..5764ac2c1f 100644
--- a/packages/sheets-formula-ui/src/views/formula-editor/hooks/use-refactor-effect.ts
+++ b/packages/sheets-formula-ui/src/views/formula-editor/hooks/use-refactor-effect.ts
@@ -40,7 +40,7 @@ export const useRefactorEffect = (isNeed: boolean, selecting: boolean, unitId: s
return () => {
const currentDoc = univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_DOC)!;
- if (currentDoc.getUnitId() === editorId) {
+ if (currentDoc?.getUnitId() === editorId) {
contextService.setContextValue(EDITOR_ACTIVATED, false);
}