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(ui-sheets): fix potential null subscription handling (#333)

白熱686541ac044a
diff --git a/packages/ui-plugin-sheets/src/View/EditorContainer/EditorContainer.tsx b/packages/ui-plugin-sheets/src/View/EditorContainer/EditorContainer.tsx
index 801b51dc17..2566e4463e 100644
--- a/packages/ui-plugin-sheets/src/View/EditorContainer/EditorContainer.tsx
+++ b/packages/ui-plugin-sheets/src/View/EditorContainer/EditorContainer.tsx
@@ -40,7 +40,7 @@ export const EditorContainer: React.FC<ICellIEditorProps> = () => {
let subscription: Subscription;
renderManagerService.currentRender$.subscribe((unitId) => {
- if (unitId !== DOCS_NORMAL_EDITOR_UNIT_ID_KEY || isLoaded === true) {
+ if (unitId !== DOCS_NORMAL_EDITOR_UNIT_ID_KEY || isLoaded) {
return;
}
@@ -58,7 +58,7 @@ export const EditorContainer: React.FC<ICellIEditorProps> = () => {
show = false,
} = param;
- if (show === false) {
+ if (!show) {
setState({
...EDITOR_DEFAULT_POSITION,
});
@@ -79,7 +79,7 @@ export const EditorContainer: React.FC<ICellIEditorProps> = () => {
// Clean up on unmount
return () => {
- subscription.unsubscribe();
+ subscription?.unsubscribe();
};
}, []); // Empty dependency array means this effect runs once on mount and clean up on unmount
@@ -97,7 +97,7 @@ export const EditorContainer: React.FC<ICellIEditorProps> = () => {
height: state.height,
}}
>
- <div className={styles.editorInput} ref={editorRef}></div>
+ <div className={styles.editorInput} ref={editorRef} />
</div>
);
};