From 7cca2d9247ab4d9cb63ca8549bbddfb4540c87b9 Mon Sep 17 00:00:00 2001 From: azivner Date: Mon, 13 Aug 2018 08:42:37 +0200 Subject: [PATCH] realoding tree doesn't steal focus (important for promoted attribute changes with attached scripts) --- src/public/javascripts/services/tree.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/public/javascripts/services/tree.js b/src/public/javascripts/services/tree.js index a6dcf24bf..15c86ca58 100644 --- a/src/public/javascripts/services/tree.js +++ b/src/public/javascripts/services/tree.js @@ -105,9 +105,13 @@ async function activateNode(notePath) { const node = await expandToNote(notePath); - await node.setActive(); + // we use noFocus because when we reload the tree because of background changes + // we don't want the reload event to steal focus from whatever was focused before + await node.setActive(true, { noFocus: true }); clearSelectedNodes(); + + return node; } /** @@ -283,11 +287,11 @@ async function treeInitialized() { } if (startNotePath) { - await activateNode(startNotePath); + const node = await activateNode(startNotePath); // looks like this this doesn't work when triggered immediatelly after activating node // so waiting a second helps - setTimeout(scrollToCurrentNote, 1000); + setTimeout(() => node.makeVisible({scrollIntoView: true}), 1000); } }