mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 18:08:33 +02:00
fix putting focus back to the note tree after note deletion
This commit is contained in:
parent
c6c9202c00
commit
f27370d44f
@ -993,6 +993,9 @@ export default class NoteTreeWidget extends TabAwareWidget {
|
|||||||
const activeNodeFocused = activeNode && activeNode.hasFocus();
|
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;
|
||||||
|
|
||||||
|
console.log(activeNotePath, activeNodeFocused);
|
||||||
|
|
||||||
const nextNotePath = nextNode ? treeService.getNotePath(nextNode) : null;
|
const nextNotePath = nextNode ? treeService.getNotePath(nextNode) : null;
|
||||||
const activeNoteId = activeNode ? activeNode.data.noteId : null;
|
const activeNoteId = activeNode ? activeNode.data.noteId : null;
|
||||||
|
|
||||||
@ -1113,7 +1116,7 @@ export default class NoteTreeWidget extends TabAwareWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (node) {
|
if (node) {
|
||||||
node.setActive(true, {noEvents: true, noFocus: true});
|
node.setActive(true, {noEvents: true, noFocus: !activeNodeFocused});
|
||||||
}
|
}
|
||||||
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
|
||||||
@ -1125,15 +1128,15 @@ export default class NoteTreeWidget extends TabAwareWidget {
|
|||||||
// this should be done by tabcontext / tabmanager and note tree should only listen to
|
// this should be done by tabcontext / tabmanager and note tree should only listen to
|
||||||
// changes in active note and just set the "active" state
|
// changes in active note and just set the "active" state
|
||||||
// We don't await since that can bring up infinite cycles when e.g. custom widget does some backend requests which wait for max sync ID processed
|
// We don't await since that can bring up infinite cycles when e.g. custom widget does some backend requests which wait for max sync ID processed
|
||||||
appContext.tabManager.getActiveTabContext().setNote(nextNotePath);
|
appContext.tabManager.getActiveTabContext().setNote(nextNotePath).then(() => {
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const newActiveNode = this.getActiveNode();
|
const newActiveNode = this.getActiveNode();
|
||||||
|
|
||||||
// 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) {console.log("FOCUSING!!!");
|
||||||
await newActiveNode.setFocus(true);
|
newActiveNode.setFocus(true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user