From 91e78998d18b46a9f8573fc3bbde35966c131c14 Mon Sep 17 00:00:00 2001 From: zadam Date: Mon, 10 Jan 2022 20:44:59 +0100 Subject: [PATCH] unified Jump-To and quick search behavior with regards to hoisting and opening in a new tab --- src/public/app/services/root_command_executor.js | 5 ++++- src/public/app/services/tab_manager.js | 4 ++-- src/public/app/widgets/quick_search.js | 8 +++----- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/public/app/services/root_command_executor.js b/src/public/app/services/root_command_executor.js index 909ccd716..3817d49c0 100644 --- a/src/public/app/services/root_command_executor.js +++ b/src/public/app/services/root_command_executor.js @@ -76,7 +76,10 @@ export default class RootCommandExecutor extends Component { // force immediate search await froca.loadSearchNote(searchNote.noteId); - const noteContext = await appContext.tabManager.openContextWithNote(searchNote.noteId, true); + const activeNoteContext = appContext.tabManager.getActiveContext(); + const hoistedNoteId = activeNoteContext?.hoistedNoteId || 'root'; + + const noteContext = await appContext.tabManager.openContextWithNote(searchNote.noteId, true, null, hoistedNoteId); appContext.triggerCommand('focusOnSearchDefinition', {ntxId: noteContext.ntxId}); } diff --git a/src/public/app/services/tab_manager.js b/src/public/app/services/tab_manager.js index 3fc634ca5..2947886f6 100644 --- a/src/public/app/services/tab_manager.js +++ b/src/public/app/services/tab_manager.js @@ -206,7 +206,7 @@ export default class TabManager extends Component { await noteContext.setEmpty(); } - async openEmptyTab(ntxId, hoistedNoteId = 'root', mainNtxId = null) { + async openEmptyTab(ntxId = null, hoistedNoteId = 'root', mainNtxId = null) { const noteContext = new NoteContext(ntxId, hoistedNoteId, mainNtxId); const existingNoteContext = this.children.find(nc => nc.ntxId === noteContext.ntxId); @@ -240,7 +240,7 @@ export default class TabManager extends Component { return this.openContextWithNote(notePath, activate, null, hoistedNoteId); } - async openContextWithNote(notePath, activate, ntxId, hoistedNoteId = 'root', mainNtxId = null) { + async openContextWithNote(notePath, activate, ntxId = null, hoistedNoteId = 'root', mainNtxId = null) { const noteContext = await this.openEmptyTab(ntxId, hoistedNoteId, mainNtxId); if (notePath) { diff --git a/src/public/app/widgets/quick_search.js b/src/public/app/widgets/quick_search.js index 2ae905ac2..6337f4dd0 100644 --- a/src/public/app/widgets/quick_search.js +++ b/src/public/app/widgets/quick_search.js @@ -150,11 +150,9 @@ export default class QuickSearchWidget extends BasicWidget { async showInFullSearch() { this.$dropdownToggle.dropdown("hide"); - const searchNote = await dateNotesService.createSearchNote({searchString: this.$searchString.val()}); - - await froca.loadSearchNote(searchNote.noteId); - - await appContext.tabManager.getActiveContext().setNote(searchNote.noteId); + await appContext.triggerCommand('searchNotes', { + searchString: this.$searchString.val() + }); } quickSearchEvent() {