fix: 搜索框用中文输入法输入单词回车不应该直接触发搜索 #334

This commit is contained in:
Hakadao
2024-02-29 00:09:57 -03:00
parent 5af83faefa
commit 6adfe9c6e9

View File

@@ -128,6 +128,13 @@ function handleKeyDown() {
})
}
function handleKeyEnter(e: KeyboardEvent) {
if (!e.shiftKey && e.key === 'Enter' && !e.isComposing) {
e.preventDefault()
navigateToSearchResultPage(keyword.value)
}
}
async function handleClearSearchHistory() {
await clearAllSearchHistory()
searchHistory.value = []
@@ -175,7 +182,7 @@ async function handleClearSearchHistory() {
type="text"
@focus="isFocus = true"
@input="handleInput"
@keyup.enter.stop.passive="navigateToSearchResultPage(keyword)"
@keydown.enter.stop.passive="handleKeyEnter"
@keyup.up.stop.passive="handleKeyUp"
@keyup.down.stop.passive="handleKeyDown"
@keydown.stop="() => {}"