Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
fix focusing title after creating a note
zadam58fa0832f6d2
diff --git a/src/public/app/services/main_tree_executors.js b/src/public/app/services/main_tree_executors.jsindex a365393f3c..9a8306fad3 100644--- a/src/public/app/services/main_tree_executors.js+++ b/src/public/app/services/main_tree_executors.js@@ -34,7 +34,7 @@ export default class MainTreeExecutors extends Component {return;}- const {note} = await noteCreateService.createNote(activeNote.noteId, {+ await noteCreateService.createNote(activeNote.noteId, {isProtected: activeNote.isProtected,saveSelection: false});@@ -56,4 +56,4 @@ export default class MainTreeExecutors extends Component {saveSelection: false});}-}\ No newline at end of file+}diff --git a/src/public/app/services/tab_context.js b/src/public/app/services/tab_context.jsindex 9d46e2f6d7..920a186f33 100644--- a/src/public/app/services/tab_context.js+++ b/src/public/app/services/tab_context.js@@ -73,7 +73,7 @@ class TabContext extends Component {protectedSessionHolder.touchProtectedSessionIfNecessary(this.note);if (triggerSwitchEvent) {- this.triggerEvent('tabNoteSwitched', {+ await this.triggerEvent('tabNoteSwitched', {tabContext: this,notePath: this.notePath});@@ -127,4 +127,4 @@ class TabContext extends Component {}}-export default TabContext;\ No newline at end of file+export default TabContext;diff --git a/src/public/app/services/tab_manager.js b/src/public/app/services/tab_manager.jsindex 40f29f8c9e..0c169cba7e 100644--- a/src/public/app/services/tab_manager.js+++ b/src/public/app/services/tab_manager.js@@ -203,7 +203,7 @@ export default class TabManager extends Component {if (activate) {this.activateTab(tabContext.tabId, false);- this.triggerEvent('tabNoteSwitchedAndActivated', {+ await this.triggerEvent('tabNoteSwitchedAndActivated', {tabContext,notePath: tabContext.notePath // resolved note path});diff --git a/src/public/app/widgets/note_tree.js b/src/public/app/widgets/note_tree.jsindex 12eb68b09d..a4006fe19e 100644--- a/src/public/app/widgets/note_tree.js+++ b/src/public/app/widgets/note_tree.js@@ -854,8 +854,11 @@ export default class NoteTreeWidget extends TabAwareWidget {this.toggleInt(this.isEnabled());const oldActiveNode = this.getActiveNode();+ let oldActiveNodeFocused = false;if (oldActiveNode) {+ oldActiveNodeFocused = oldActiveNode.hasFocus();+oldActiveNode.setActive(false);oldActiveNode.setFocus(false);}@@ -868,8 +871,7 @@ export default class NoteTreeWidget extends TabAwareWidget {await this.expandToNote(this.tabContext.notePath);}- newActiveNode.setActive(true, {noEvents: true});-+ newActiveNode.setActive(true, {noEvents: true, noFocus: !oldActiveNodeFocused});newActiveNode.makeVisible({scrollIntoView: true});}}@@ -898,7 +900,7 @@ export default class NoteTreeWidget extends TabAwareWidget {async entitiesReloadedEvent({loadResults}) {const activeNode = this.getActiveNode();- const activeNodeFocused = activeNode ? activeNode.hasFocus() : false;+ const activeNodeFocused = activeNode && activeNode.hasFocus();const nextNode = activeNode ? (activeNode.getNextSibling() || activeNode.getPrevSibling() || activeNode.getParent()) : null;const activeNotePath = activeNode ? treeService.getNotePath(activeNode) : null;const nextNotePath = nextNode ? treeService.getNotePath(nextNode) : null;@@ -1021,7 +1023,7 @@ export default class NoteTreeWidget extends TabAwareWidget {}if (node) {- node.setActive(true, {noEvents: true});+ node.setActive(true, {noEvents: true, noFocus: true});}else {// this is used when original note has been deleted and we want to move the focus to the note above/below@@ -1036,7 +1038,7 @@ export default class NoteTreeWidget extends TabAwareWidget {// return focus if the previously active node was also focusedif (newActiveNode && activeNodeFocused) {- newActiveNode.setFocus(true);+ await newActiveNode.setFocus(true);}}}@@ -1064,7 +1066,7 @@ export default class NoteTreeWidget extends TabAwareWidget {if (activeNotePath) {const node = await this.getNodeFromPath(activeNotePath, true);- await node.setActive(true, {noEvents: true});+ await node.setActive(true, {noEvents: true, noFocus: true});}}