Skip to content

Build your personal knowledge base with Trilium Notes

fixed race condition when changing note path in URL hash which caused flickering

azivnerf07c427da1cd
diff --git a/public/javascripts/note_tree.js b/public/javascripts/note_tree.js
index d560c1df8a..a09d98350d 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 223312f4b2..4fcbd381a5 100644
--- a/public/stylesheets/style.css
+++ b/public/stylesheets/style.css
@@ -175,7 +175,6 @@ div.ui-tooltip {
/* Allow to use <kbd> 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 {