Skip to content

Build your personal knowledge base with Trilium Notes

fix "go to note" from note autocomplete

zadam274505188bdb
diff --git a/src/public/app/services/link.js b/src/public/app/services/link.js
index e077bfd1fc..0233aec820 100644
--- a/src/public/app/services/link.js
+++ b/src/public/app/services/link.js
@@ -108,12 +108,16 @@ function calculateHash({notePath, ntxId, hoistedNoteId, viewScope = {}}) {
}
function parseNavigationStateFromUrl(url) {
- const hashIdx = url?.indexOf('#');
+ if (!url) {
+ return {};
+ }
+
+ const hashIdx = url.indexOf('#');
if (hashIdx === -1) {
return {};
}
- const hash = url?.substr(hashIdx + 1); // strip also the initial '#'
+ const hash = url.substr(hashIdx + 1); // strip also the initial '#'
const [notePath, paramString] = hash.split("?");
const viewScope = {
viewMode: 'default'
diff --git a/src/public/app/services/note_autocomplete.js b/src/public/app/services/note_autocomplete.js
index 3eda517ef8..891f0ebb35 100644
--- a/src/public/app/services/note_autocomplete.js
+++ b/src/public/app/services/note_autocomplete.js
@@ -247,7 +247,7 @@ function init() {
.closest(".input-group")
.find(".go-to-selected-note-button")
.toggleClass("disabled", !notePath.trim())
- .attr(SELECTED_NOTE_PATH_KEY, notePath); // we also set attr here so tooltip can be displayed
+ .attr("href", `#${notePath}`); // we also set href here so tooltip can be displayed
};
$.fn.getSelectedExternalLink = function () {
@@ -259,12 +259,14 @@ function init() {
};
$.fn.setSelectedExternalLink = function (externalLink) {
- $(this).attr(SELECTED_EXTERNAL_LINK_KEY, externalLink);
+ console.trace("setSelectedExternalLink");
- $(this)
- .closest(".input-group")
- .find(".go-to-selected-note-button")
- .toggleClass("disabled", true);
+ if (externalLink) {
+ $(this)
+ .closest(".input-group")
+ .find(".go-to-selected-note-button")
+ .toggleClass("disabled", true);
+ }
}
$.fn.setNote = async function (noteId) {