mirror of
https://github.com/zadam/trilium.git
synced 2025-11-28 19:44:24 +01:00
fix(split): only trigger focusOnDetail when necessary
This commit is contained in:
parent
210dcfb989
commit
407cac588a
@ -487,7 +487,7 @@ type EventMappings = {
|
|||||||
relationMapResetPanZoom: { ntxId: string | null | undefined };
|
relationMapResetPanZoom: { ntxId: string | null | undefined };
|
||||||
relationMapResetZoomIn: { ntxId: string | null | undefined };
|
relationMapResetZoomIn: { ntxId: string | null | undefined };
|
||||||
relationMapResetZoomOut: { ntxId: string | null | undefined };
|
relationMapResetZoomOut: { ntxId: string | null | undefined };
|
||||||
activeNoteChanged: {};
|
activeNoteChanged: {ntxId: string | null | undefined};
|
||||||
showAddLinkDialog: AddLinkOpts;
|
showAddLinkDialog: AddLinkOpts;
|
||||||
showIncludeDialog: IncludeNoteOpts;
|
showIncludeDialog: IncludeNoteOpts;
|
||||||
openBulkActionsDialog: {
|
openBulkActionsDialog: {
|
||||||
|
|||||||
@ -165,7 +165,7 @@ export default class TabManager extends Component {
|
|||||||
const activeNoteContext = this.getActiveContext();
|
const activeNoteContext = this.getActiveContext();
|
||||||
this.updateDocumentTitle(activeNoteContext);
|
this.updateDocumentTitle(activeNoteContext);
|
||||||
|
|
||||||
this.triggerEvent("activeNoteChanged", {}); // trigger this even in on popstate event
|
this.triggerEvent("activeNoteChanged", {ntxId:activeNoteContext?.ntxId}); // trigger this even in on popstate event
|
||||||
}
|
}
|
||||||
|
|
||||||
calculateHash(): string {
|
calculateHash(): string {
|
||||||
|
|||||||
@ -95,9 +95,11 @@ export default function NoteDetail() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Automatically focus the editor.
|
// Automatically focus the editor.
|
||||||
useTriliumEvent("activeNoteChanged", () => {
|
useTriliumEvent("activeNoteChanged", ({ ntxId: eventNtxId }) => {
|
||||||
// Restore focus to the editor when switching tabs, but only if the note tree is not already focused.
|
if (eventNtxId != ntxId) return;
|
||||||
if (!document.activeElement?.classList.contains("fancytree-title")) {
|
// Restore focus to the editor when switching tabs,
|
||||||
|
// but only if the note tree and the note panel (e.g., note title or note detail) are not focused.
|
||||||
|
if (!document.activeElement?.classList.contains("fancytree-title") && !parentComponent.$widget[0].closest(".note-split")?.contains(document.activeElement)) {
|
||||||
parentComponent.triggerCommand("focusOnDetail", { ntxId });
|
parentComponent.triggerCommand("focusOnDetail", { ntxId });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user