mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 18:36:30 +01:00 
			
		
		
		
	fix focusing title after creating a note
This commit is contained in:
		| @@ -34,7 +34,7 @@ export default class MainTreeExecutors extends Component { | |||||||
|             return; |             return; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         const {note} = await noteCreateService.createNote(activeNote.noteId, { |         await noteCreateService.createNote(activeNote.noteId, { | ||||||
|             isProtected: activeNote.isProtected, |             isProtected: activeNote.isProtected, | ||||||
|             saveSelection: false |             saveSelection: false | ||||||
|         }); |         }); | ||||||
| @@ -56,4 +56,4 @@ export default class MainTreeExecutors extends Component { | |||||||
|             saveSelection: false |             saveSelection: false | ||||||
|         }); |         }); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -73,7 +73,7 @@ class TabContext extends Component { | |||||||
|         protectedSessionHolder.touchProtectedSessionIfNecessary(this.note); |         protectedSessionHolder.touchProtectedSessionIfNecessary(this.note); | ||||||
|  |  | ||||||
|         if (triggerSwitchEvent) { |         if (triggerSwitchEvent) { | ||||||
|             this.triggerEvent('tabNoteSwitched', { |             await this.triggerEvent('tabNoteSwitched', { | ||||||
|                 tabContext: this, |                 tabContext: this, | ||||||
|                 notePath: this.notePath |                 notePath: this.notePath | ||||||
|             }); |             }); | ||||||
| @@ -127,4 +127,4 @@ class TabContext extends Component { | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| export default TabContext; | export default TabContext; | ||||||
|   | |||||||
| @@ -203,7 +203,7 @@ export default class TabManager extends Component { | |||||||
|         if (activate) { |         if (activate) { | ||||||
|             this.activateTab(tabContext.tabId, false); |             this.activateTab(tabContext.tabId, false); | ||||||
|  |  | ||||||
|             this.triggerEvent('tabNoteSwitchedAndActivated', { |             await this.triggerEvent('tabNoteSwitchedAndActivated', { | ||||||
|                 tabContext, |                 tabContext, | ||||||
|                 notePath: tabContext.notePath // resolved note path |                 notePath: tabContext.notePath // resolved note path | ||||||
|             }); |             }); | ||||||
|   | |||||||
| @@ -854,8 +854,11 @@ export default class NoteTreeWidget extends TabAwareWidget { | |||||||
|         this.toggleInt(this.isEnabled()); |         this.toggleInt(this.isEnabled()); | ||||||
|  |  | ||||||
|         const oldActiveNode = this.getActiveNode(); |         const oldActiveNode = this.getActiveNode(); | ||||||
|  |         let oldActiveNodeFocused = false; | ||||||
|  |  | ||||||
|         if (oldActiveNode) { |         if (oldActiveNode) { | ||||||
|  |             oldActiveNodeFocused = oldActiveNode.hasFocus(); | ||||||
|  |  | ||||||
|             oldActiveNode.setActive(false); |             oldActiveNode.setActive(false); | ||||||
|             oldActiveNode.setFocus(false); |             oldActiveNode.setFocus(false); | ||||||
|         } |         } | ||||||
| @@ -868,8 +871,7 @@ export default class NoteTreeWidget extends TabAwareWidget { | |||||||
|                     await this.expandToNote(this.tabContext.notePath); |                     await this.expandToNote(this.tabContext.notePath); | ||||||
|                 } |                 } | ||||||
|  |  | ||||||
|                 newActiveNode.setActive(true, {noEvents: true}); |                 newActiveNode.setActive(true, {noEvents: true, noFocus: !oldActiveNodeFocused}); | ||||||
|  |  | ||||||
|                 newActiveNode.makeVisible({scrollIntoView: true}); |                 newActiveNode.makeVisible({scrollIntoView: true}); | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
| @@ -898,7 +900,7 @@ export default class NoteTreeWidget extends TabAwareWidget { | |||||||
|  |  | ||||||
|     async entitiesReloadedEvent({loadResults}) { |     async entitiesReloadedEvent({loadResults}) { | ||||||
|         const activeNode = this.getActiveNode(); |         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 nextNode = activeNode ? (activeNode.getNextSibling() || activeNode.getPrevSibling() || activeNode.getParent()) : null; | ||||||
|         const activeNotePath = activeNode ? treeService.getNotePath(activeNode) : null; |         const activeNotePath = activeNode ? treeService.getNotePath(activeNode) : null; | ||||||
|         const nextNotePath = nextNode ? treeService.getNotePath(nextNode) : null; |         const nextNotePath = nextNode ? treeService.getNotePath(nextNode) : null; | ||||||
| @@ -1021,7 +1023,7 @@ export default class NoteTreeWidget extends TabAwareWidget { | |||||||
|             } |             } | ||||||
|  |  | ||||||
|             if (node) { |             if (node) { | ||||||
|                 node.setActive(true, {noEvents: true}); |                 node.setActive(true, {noEvents: true, noFocus: true}); | ||||||
|             } |             } | ||||||
|             else { |             else { | ||||||
|                 // this is used when original note has been deleted and we want to move the focus to the note above/below |                 // 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 focused |             // return focus if the previously active node was also focused | ||||||
|             if (newActiveNode && activeNodeFocused) { |             if (newActiveNode && activeNodeFocused) { | ||||||
|                 newActiveNode.setFocus(true); |                 await newActiveNode.setFocus(true); | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| @@ -1064,7 +1066,7 @@ export default class NoteTreeWidget extends TabAwareWidget { | |||||||
|         if (activeNotePath) { |         if (activeNotePath) { | ||||||
|             const node = await this.getNodeFromPath(activeNotePath, true); |             const node = await this.getNodeFromPath(activeNotePath, true); | ||||||
|  |  | ||||||
|             await node.setActive(true, {noEvents: true}); |             await node.setActive(true, {noEvents: true, noFocus: true}); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user