Skip to content

Commit

Permalink
fix: cannot click on editor space to lose focus
Browse files Browse the repository at this point in the history
  • Loading branch information
Quorafind committed Feb 6, 2025
1 parent 580e113 commit 857da5e
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/editor-ext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,21 @@ export const editorExt = (app: App) => {
}
},
blur: (event, view) => {
// Only trigger blur when actually leaving the editor
if (event.relatedTarget && !view.dom.contains(event.relatedTarget as Node)) {
// Only trigger blur when actually leaving the editor or clicking metadata/title
if (
event.target instanceof HTMLElement &&
(!event.relatedTarget ||
!view.dom.contains(event.relatedTarget as Node) ||
event.target.closest(".metadata-container") ||
event.target.closest(".inline-title"))
) {
lastFocusState = false;
app.workspace.trigger("shortcuts:editor-focus-change", {
focusing: false,
focusing: false,
editor: view.state.field(editorInfoField).editor,
pos: view.state.selection.main,
});
}
}
},
});
};

0 comments on commit 857da5e

Please sign in to comment.