From f07c427da1cd4092452a17d70d3b7c1de2aead9f Mon Sep 17 00:00:00 2001 From: azivner Date: Mon, 1 Jan 2018 18:53:52 -0500 Subject: [PATCH] fixed race condition when changing note path in URL hash which caused flickering --- public/javascripts/note_tree.js | 16 ++++++++++++---- public/stylesheets/style.css | 2 +- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/public/javascripts/note_tree.js b/public/javascripts/note_tree.js index d560c1df8..a09d98350 100644 --- a/public/javascripts/note_tree.js +++ b/public/javascripts/note_tree.js @@ -209,8 +209,6 @@ const noteTree = (function() { let parentNoteId = 'root'; - //console.log(now(), "Run path: ", runPath); - for (const childNoteId of runPath) { const node = getNodesByNoteId(childNoteId).find(node => node.data.parent_note_id === parentNoteId); @@ -223,6 +221,8 @@ const noteTree = (function() { parentNoteId = childNoteId; } + + clearSelectedNodes(); } /** @@ -391,7 +391,11 @@ const noteTree = (function() { selectedNode.setSelected(false); } - getCurrentNode().setSelected(true); + const currentNode = getCurrentNode(); + + if (currentNode) { + currentNode.setSelected(true); + } } function initFancyTree(noteTree) { @@ -803,7 +807,11 @@ const noteTree = (function() { $(window).bind('hashchange', function() { const notePath = getNotePathFromAddress(); - activateNode(notePath); + if (getCurrentNotePath() !== notePath) { + console.log("Switching to " + notePath + " because of hash change"); + + activateNode(notePath); + } }); if (isElectron()) { diff --git a/public/stylesheets/style.css b/public/stylesheets/style.css index 223312f4b..4fcbd381a 100644 --- a/public/stylesheets/style.css +++ b/public/stylesheets/style.css @@ -175,7 +175,6 @@ div.ui-tooltip { /* Allow to use elements inside the title to define shortcut hints. */ .ui-menu kbd, button kbd { - float: right; color: black; border: none; background-color: transparent; @@ -184,6 +183,7 @@ div.ui-tooltip { .ui-menu kbd { margin-left: 30px; + float: right; } #note-id-display {