Skip to content

Build your personal knowledge base with Trilium Notes

toggling the left pane will toggle the focus between tree and detail, #3563

zadam2e181d0fb1ea
diff --git a/src/public/app/widgets/containers/left_pane_container.js b/src/public/app/widgets/containers/left_pane_container.js
index 5c6c065509..fa1915a1e3 100644
--- a/src/public/app/widgets/containers/left_pane_container.js
+++ b/src/public/app/widgets/containers/left_pane_container.js
@@ -1,5 +1,6 @@
import options from "../../services/options.js";
import FlexContainer from "./flex_container.js";
+import appContext from "../../components/app_context.js";
export default class LeftPaneContainer extends FlexContainer {
constructor() {
@@ -16,7 +17,15 @@ export default class LeftPaneContainer extends FlexContainer {
entitiesReloadedEvent({loadResults}) {
if (loadResults.isOptionReloaded("leftPaneVisible")) {
- this.toggleInt(this.isEnabled());
+ const visible = this.isEnabled();
+ this.toggleInt(visible);
+
+ if (visible) {
+ this.triggerEvent('focusTree');
+ } else {
+ const activeNoteContext = appContext.tabManager.getActiveContext();
+ this.triggerEvent('focusOnDetail', {ntxId: activeNoteContext.ntxId});
+ }
}
}
}
diff --git a/src/public/app/widgets/note_tree.js b/src/public/app/widgets/note_tree.js
index 0d911fd476..509e2dd104 100644
--- a/src/public/app/widgets/note_tree.js
+++ b/src/public/app/widgets/note_tree.js
@@ -887,6 +887,11 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {
}
}
+ async focusTreeEvent() {
+ this.tree.$container.focus();
+ this.tree.setFocus(true);
+ }
+
/** @returns {FancytreeNode} */
async getNodeFromPath(notePath, expand = false, logErrors = true) {
utils.assertArguments(notePath);