From f0a2a6a7ae55e78bb0053f6e0baadd4c1aed167c Mon Sep 17 00:00:00 2001 From: Simon Cambier Date: Wed, 11 Jan 2023 20:10:56 +0100 Subject: [PATCH] Fixed history navigation --- src/components/InputSearch.svelte | 4 ++++ src/components/ModalVault.svelte | 8 ++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/components/InputSearch.svelte b/src/components/InputSearch.svelte index e8a5387..f303c5d 100644 --- a/src/components/InputSearch.svelte +++ b/src/components/InputSearch.svelte @@ -11,6 +11,10 @@ let elInput: HTMLInputElement const dispatch = createEventDispatcher() + export function setInputValue(v:string): void { + value = v + } + $: { if (initialValue && !initialSet && !value) { initialSet = true diff --git a/src/components/ModalVault.svelte b/src/components/ModalVault.svelte index dee76be..84065c2 100644 --- a/src/components/ModalVault.svelte +++ b/src/components/ModalVault.svelte @@ -23,6 +23,7 @@ let query: Query let indexingStepDesc = '' let searching = true + let refInput: InputSearch|undefined $: selectedNote = resultNotes[selectedIndex] $: searchQuery = searchQuery ?? previousQuery @@ -87,7 +88,8 @@ if (++historySearchIndex >= history.length) { historySearchIndex = 0 } - previousQuery = history[historySearchIndex] + searchQuery = history[historySearchIndex] + refInput?.setInputValue(searchQuery) } async function nextSearchHistory() { @@ -95,7 +97,8 @@ if (--historySearchIndex < 0) { historySearchIndex = history.length ? history.length - 1 : 0 } - previousQuery = history[historySearchIndex] + searchQuery = history[historySearchIndex] + refInput?.setInputValue(searchQuery) } async function updateResults() { @@ -230,6 +233,7 @@ {#if settings.showCreateButton}