mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
fix tree activation/focus after deleting node
This commit is contained in:
parent
c5daaf541a
commit
93f1d46104
@ -3,6 +3,7 @@ import utils from './utils.js';
|
|||||||
import server from './server.js';
|
import server from './server.js';
|
||||||
import infoService from "./info.js";
|
import infoService from "./info.js";
|
||||||
import treeCache from "./tree_cache.js";
|
import treeCache from "./tree_cache.js";
|
||||||
|
import treeUtils from "./tree_utils.js";
|
||||||
import hoistedNoteService from "./hoisted_note.js";
|
import hoistedNoteService from "./hoisted_note.js";
|
||||||
import noteDetailService from "./note_detail.js";
|
import noteDetailService from "./note_detail.js";
|
||||||
|
|
||||||
@ -105,9 +106,10 @@ async function deleteNodes(nodes) {
|
|||||||
next = nodes[0].getParent();
|
next = nodes[0].getParent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let activeNotePath = null;
|
||||||
|
|
||||||
if (next) {
|
if (next) {
|
||||||
// activate next element after this one is deleted so we don't lose focus
|
activeNotePath = await treeUtils.getNotePath(next);
|
||||||
next.setActive();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
await treeService.loadTreeCache();
|
await treeService.loadTreeCache();
|
||||||
@ -119,7 +121,15 @@ async function deleteNodes(nodes) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (const parentNoteId of parentNoteIds) {
|
for (const parentNoteId of parentNoteIds) {
|
||||||
treeService.reloadNote(parentNoteId);
|
await treeService.reloadNote(parentNoteId);
|
||||||
|
}
|
||||||
|
|
||||||
|
// activate after all the reloading
|
||||||
|
if (activeNotePath) {
|
||||||
|
treeService.focusTree();
|
||||||
|
|
||||||
|
const node = await treeService.activateNote(activeNotePath);
|
||||||
|
node.setFocus(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
infoService.showMessage("Note(s) has been deleted.");
|
infoService.showMessage("Note(s) has been deleted.");
|
||||||
|
@ -516,11 +516,15 @@ async function collapseTree(node = null) {
|
|||||||
node.visit(node => node.setExpanded(false));
|
node.visit(node => node.setExpanded(false));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function focusTree() {
|
||||||
|
$tree.find('.fancytree-container').focus();
|
||||||
|
}
|
||||||
|
|
||||||
async function scrollToActiveNote() {
|
async function scrollToActiveNote() {
|
||||||
const activeContext = noteDetailService.getActiveTabContext();
|
const activeContext = noteDetailService.getActiveTabContext();
|
||||||
|
|
||||||
if (activeContext && activeContext.notePath) {
|
if (activeContext && activeContext.notePath) {
|
||||||
$tree.find('.fancytree-container').focus();
|
focusTree();
|
||||||
|
|
||||||
const node = await expandToNote(activeContext.notePath);
|
const node = await expandToNote(activeContext.notePath);
|
||||||
|
|
||||||
@ -814,5 +818,6 @@ export default {
|
|||||||
expandToNote,
|
expandToNote,
|
||||||
getNodeFromPath,
|
getNodeFromPath,
|
||||||
resolveNotePath,
|
resolveNotePath,
|
||||||
getSomeNotePath
|
getSomeNotePath,
|
||||||
|
focusTree
|
||||||
};
|
};
|
Loading…
x
Reference in New Issue
Block a user