Make autocomplete start with 0

This commit is contained in:
kwaroran
2024-09-24 02:05:25 +09:00
parent dfe5fe3503
commit 257de38867

View File

@@ -132,7 +132,7 @@
export let className = '' export let className = ''
export let optimaizedInput = true export let optimaizedInput = true
export let highlight = false export let highlight = false
let selectingAutoComplete = -1 let selectingAutoComplete = 0
let highlightId = highlight ? getNewHighlightId() : 0 let highlightId = highlight ? getNewHighlightId() : 0
let inpa = 0 let inpa = 0
let highlightDom: HTMLDivElement let highlightDom: HTMLDivElement
@@ -146,7 +146,7 @@
return return
} }
//autocomplete //autocomplete
selectingAutoComplete = -1 selectingAutoComplete = 0
const sel = window.getSelection() const sel = window.getSelection()
if(!sel){ if(!sel){
return return
@@ -222,7 +222,7 @@
const hideAutoComplete = () => { const hideAutoComplete = () => {
autoCompleteDom.style.display = 'none' autoCompleteDom.style.display = 'none'
selectingAutoComplete = -1 selectingAutoComplete = 0
autocompleteContents = [] autocompleteContents = []
} }
@@ -253,9 +253,7 @@
case 'Enter': case 'Enter':
case 'Tab': case 'Tab':
e.preventDefault() e.preventDefault()
if(selectingAutoComplete !== -1){ insertContent(autocompleteContents[selectingAutoComplete])
insertContent(autocompleteContents[selectingAutoComplete])
}
return return
case 'Escape': case 'Escape':
hideAutoComplete() hideAutoComplete()