Fixed history navigation

This commit is contained in:
Simon Cambier
2023-01-11 20:10:56 +01:00
parent 54abf8a106
commit f0a2a6a7ae
2 changed files with 10 additions and 2 deletions

View File

@@ -11,6 +11,10 @@
let elInput: HTMLInputElement
const dispatch = createEventDispatcher()
export function setInputValue(v:string): void {
value = v
}
$: {
if (initialValue && !initialSet && !value) {
initialSet = true

View File

@@ -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 @@
<InputSearch
initialValue="{searchQuery}"
bind:this={refInput}
on:input="{e => (searchQuery = e.detail)}"
placeholder="Omnisearch - Vault">
{#if settings.showCreateButton}