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.
TypeScript boardcollaborationdocdocxexceloffce365officepdfpptpptxpresentationsdksheetslidesspreadsheetuniverwordwordprocessorworkspacexlsx
fix: fix doc editor cannot focus
Wenzhao Huab4fe643ecc0
diff --git a/packages/ui/src/services/layout/layout.service.ts b/packages/ui/src/services/layout/layout.service.tsindex 42bf60d975..08117f77fb 100644--- a/packages/ui/src/services/layout/layout.service.ts+++ b/packages/ui/src/services/layout/layout.service.ts@@ -156,7 +156,7 @@ export class DesktopLayoutService extends Disposable implements ILayoutService {fromEvent(window, 'focusin').subscribe((event) => {const target = event.target as HTMLElement;if (givingBackFocusElements.some((item) => target.classList.contains(item))) {- this._blurEditor();+ this._blurSheetEditor();queueMicrotask(() => this.focus());return;}@@ -174,15 +174,13 @@ export class DesktopLayoutService extends Disposable implements ILayoutService {}private _initEditorStatus(): void {- this._contextService.setContextValue(- FOCUSING_UNIVER_EDITOR,- getFocusingUniverEditorStatus()- );+ this._contextService.setContextValue(FOCUSING_UNIVER_EDITOR, getFocusingUniverEditorStatus());}- private _blurEditor() {+ private _blurSheetEditor() {+ // NOTE: Note that the focus editor will not be docs' editor but calling `this._editorService.blur()` will blur doc's editor.const focusEditor = this._editorService.getFocusEditor();- if (focusEditor?.isSheetEditor() !== true) {+ if (focusEditor && focusEditor.isSheetEditor() !== true) {this._editorService.blur();}}