diff --git a/package-lock.json b/package-lock.json index 96a1faf7a..1b4d03f56 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "trilium", - "version": "0.33.4", + "version": "0.33.5", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/src/public/javascripts/dialogs/confirm.js b/src/public/javascripts/dialogs/confirm.js index 5a103ca70..efbc686df 100644 --- a/src/public/javascripts/dialogs/confirm.js +++ b/src/public/javascripts/dialogs/confirm.js @@ -7,8 +7,11 @@ const $custom = $("#confirm-dialog-custom"); const DELETE_NOTE_BUTTON_ID = "confirm-dialog-delete-note"; let resolve; +let $originallyFocused; // element focused before the dialog was opened so we can return to it afterwards function confirm(message) { + $originallyFocused = $(':focus'); + $custom.hide(); glob.activeDialog = $dialog; @@ -55,6 +58,11 @@ $dialog.on("hidden.bs.modal", () => { if (resolve) { resolve(false); } + + if ($originallyFocused) { + $originallyFocused.focus(); + $originallyFocused = null; + } }); function doResolve(ret) { diff --git a/src/public/javascripts/dialogs/info.js b/src/public/javascripts/dialogs/info.js index 35e067741..5a1eb3193 100644 --- a/src/public/javascripts/dialogs/info.js +++ b/src/public/javascripts/dialogs/info.js @@ -5,8 +5,11 @@ const $infoContent = $("#info-dialog-content"); const $okButton = $("#info-dialog-ok-button"); let resolve; +let $originallyFocused; // element focused before the dialog was opened so we can return to it afterwards function info(message) { + $originallyFocused = $(':focus'); + utils.closeActiveDialog(); glob.activeDialog = $dialog; @@ -24,6 +27,11 @@ $dialog.on("hidden.bs.modal", () => { if (resolve) { resolve(); } + + if ($originallyFocused) { + $originallyFocused.focus(); + $originallyFocused = null; + } }); $okButton.click(() => $dialog.modal("hide")); diff --git a/src/public/javascripts/services/branches.js b/src/public/javascripts/services/branches.js index fc2983f9d..dbcda42cf 100644 --- a/src/public/javascripts/services/branches.js +++ b/src/public/javascripts/services/branches.js @@ -6,6 +6,7 @@ import treeCache from "./tree_cache.js"; import treeUtils from "./tree_utils.js"; import hoistedNoteService from "./hoisted_note.js"; import noteDetailService from "./note_detail.js"; +import confirmDialog from "../dialogs/confirm.js"; async function moveBeforeNode(nodesToMove, beforeNode) { nodesToMove = await filterRootNote(nodesToMove); @@ -82,7 +83,7 @@ async function moveToNode(nodesToMove, toNode) { async function deleteNodes(nodes) { nodes = await filterRootNote(nodes); - if (nodes.length === 0 || !confirm('Are you sure you want to delete select note(s) and all the sub-notes?')) { + if (nodes.length === 0 || !await confirmDialog.confirm('Are you sure you want to delete select note(s) and all the sub-notes?')) { return false; } diff --git a/src/public/javascripts/services/note_detail_text.js b/src/public/javascripts/services/note_detail_text.js index de75a1763..9c8f1204c 100644 --- a/src/public/javascripts/services/note_detail_text.js +++ b/src/public/javascripts/services/note_detail_text.js @@ -74,7 +74,7 @@ class NoteDetailText { } focus() { - this.$component.focus(); + this.$editorEl.focus(); } getEditor() { diff --git a/src/public/javascripts/services/tree.js b/src/public/javascripts/services/tree.js index 36c8d9bb5..fe2cad5b4 100644 --- a/src/public/javascripts/services/tree.js +++ b/src/public/javascripts/services/tree.js @@ -635,6 +635,8 @@ async function createNote(node, parentNoteId, target, extraOptions = {}) { }; if (target === 'after') { + console.log(`Appending node...`); // to debug duplicated nodes + await node.appendSibling(newNode).setActive(true); } else if (target === 'into') { @@ -642,6 +644,8 @@ async function createNote(node, parentNoteId, target, extraOptions = {}) { await node.setExpanded(); } + console.log(`Adding node as child...`); // to debug duplicated nodes + node.addChildren(newNode); await node.getLastChild().setActive(true); diff --git a/src/views/tabs.ejs b/src/views/tabs.ejs index 6e68f3b7b..5f0c5560e 100644 --- a/src/views/tabs.ejs +++ b/src/views/tabs.ejs @@ -11,8 +11,8 @@
-
-
+
+