Skip to content

Commit

Permalink
fix: fix doc editor cannot focus
Browse files Browse the repository at this point in the history
  • Loading branch information
wzhudev committed Apr 28, 2024
1 parent 4a360f7 commit ab4fe64
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions packages/ui/src/services/layout/layout.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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();
}
}
Expand Down

0 comments on commit ab4fe64

Please sign in to comment.