Fixed history navigation
This commit is contained in:
@@ -11,6 +11,10 @@
|
|||||||
let elInput: HTMLInputElement
|
let elInput: HTMLInputElement
|
||||||
const dispatch = createEventDispatcher()
|
const dispatch = createEventDispatcher()
|
||||||
|
|
||||||
|
export function setInputValue(v:string): void {
|
||||||
|
value = v
|
||||||
|
}
|
||||||
|
|
||||||
$: {
|
$: {
|
||||||
if (initialValue && !initialSet && !value) {
|
if (initialValue && !initialSet && !value) {
|
||||||
initialSet = true
|
initialSet = true
|
||||||
|
|||||||
@@ -23,6 +23,7 @@
|
|||||||
let query: Query
|
let query: Query
|
||||||
let indexingStepDesc = ''
|
let indexingStepDesc = ''
|
||||||
let searching = true
|
let searching = true
|
||||||
|
let refInput: InputSearch|undefined
|
||||||
|
|
||||||
$: selectedNote = resultNotes[selectedIndex]
|
$: selectedNote = resultNotes[selectedIndex]
|
||||||
$: searchQuery = searchQuery ?? previousQuery
|
$: searchQuery = searchQuery ?? previousQuery
|
||||||
@@ -87,7 +88,8 @@
|
|||||||
if (++historySearchIndex >= history.length) {
|
if (++historySearchIndex >= history.length) {
|
||||||
historySearchIndex = 0
|
historySearchIndex = 0
|
||||||
}
|
}
|
||||||
previousQuery = history[historySearchIndex]
|
searchQuery = history[historySearchIndex]
|
||||||
|
refInput?.setInputValue(searchQuery)
|
||||||
}
|
}
|
||||||
|
|
||||||
async function nextSearchHistory() {
|
async function nextSearchHistory() {
|
||||||
@@ -95,7 +97,8 @@
|
|||||||
if (--historySearchIndex < 0) {
|
if (--historySearchIndex < 0) {
|
||||||
historySearchIndex = history.length ? history.length - 1 : 0
|
historySearchIndex = history.length ? history.length - 1 : 0
|
||||||
}
|
}
|
||||||
previousQuery = history[historySearchIndex]
|
searchQuery = history[historySearchIndex]
|
||||||
|
refInput?.setInputValue(searchQuery)
|
||||||
}
|
}
|
||||||
|
|
||||||
async function updateResults() {
|
async function updateResults() {
|
||||||
@@ -230,6 +233,7 @@
|
|||||||
|
|
||||||
<InputSearch
|
<InputSearch
|
||||||
initialValue="{searchQuery}"
|
initialValue="{searchQuery}"
|
||||||
|
bind:this={refInput}
|
||||||
on:input="{e => (searchQuery = e.detail)}"
|
on:input="{e => (searchQuery = e.detail)}"
|
||||||
placeholder="Omnisearch - Vault">
|
placeholder="Omnisearch - Vault">
|
||||||
{#if settings.showCreateButton}
|
{#if settings.showCreateButton}
|
||||||
|
|||||||
Reference in New Issue
Block a user