fix: prevent keyboard events during IME composition (#1535)

This commit is contained in:
Weijie Zhao 2025-10-07 00:17:52 +08:00 committed by GitHub
parent 1af48aacb9
commit d7d3078de5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
11 changed files with 34 additions and 4 deletions

View File

@ -49,6 +49,9 @@ function onKeyDown(e: KeyboardEvent) {
if (focusedRowIndex.value === null || focusedCellIndex.value === null) return
if (e.key === 'Enter') {
if (e.isComposing) {
return
}
e.preventDefault()
emit('enterPressed', { row: focusedRow.value!, cell: focusedCellIndex.value })
return

View File

@ -36,6 +36,9 @@ function onFocus() {
function onKeyDown(e: KeyboardEvent) {
if (e.key === 'Enter' || e.key === ' ') {
if (e.isComposing) {
return
}
e.preventDefault()
onSelect()
}

View File

@ -64,6 +64,9 @@ export default {
}
if (event.key === 'Enter') {
if (event.isComposing) {
return false
}
this.enterHandler()
return true
}

View File

@ -233,6 +233,10 @@ export default function suggestionSetup(t) {
onKeyDown(props) {
if (props.event.key === 'Escape') {
if (props.event.isComposing) {
return false
}
if (popupElement) {
popupElement.style.display = 'none'
}

View File

@ -78,6 +78,9 @@ function onKeyDown({event}: { event: KeyboardEvent }) {
}
if (event.key === 'Enter') {
if (event.isComposing) {
return false
}
event.preventDefault()
event.stopPropagation()
enterHandler()

View File

@ -102,6 +102,9 @@ watchEffect(() => {
function onKeydown(e: KeyboardEvent) {
if (e.key === 'Escape') {
if (e.isComposing) {
return
}
emit('close')
}
}

View File

@ -56,8 +56,8 @@
class="title input"
:contenteditable="(bucketTitleEditable && canWrite && !collapsedBuckets[bucket.id]) ? true : undefined"
:spellcheck="false"
@keydown.enter.prevent.stop="($event.target as HTMLElement).blur()"
@keydown.esc.prevent.stop="($event.target as HTMLElement).blur()"
@keydown.enter.prevent.stop="!$event.isComposing && ($event.target as HTMLElement).blur()"
@keydown.esc.prevent.stop="!$event.isComposing && ($event.target as HTMLElement).blur()"
@blur="saveBucketTitle(bucket.id, ($event.target as HTMLElement).textContent as string)"
@click="focusBucketTitle"
>

View File

@ -314,6 +314,9 @@ function handleListNavigation(e: KeyboardEvent) {
}
if (e.key === 'Enter') {
if (e.isComposing) {
return
}
e.preventDefault()
taskRefs.value[focusedIndex.value]?.click(e)
}

View File

@ -270,6 +270,10 @@ function handleEnter(e: KeyboardEvent) {
return
}
if (e.isComposing) {
return
}
e.preventDefault()
addTask()
}

View File

@ -29,8 +29,8 @@
:contenteditable="canWrite ? true : undefined"
:spellcheck="false"
@blur="save(($event.target as HTMLInputElement).textContent as string)"
@keydown.enter.prevent.stop="($event.target as HTMLInputElement).blur()"
@keydown.esc.prevent.stop="cancel($event.target as HTMLInputElement)"
@keydown.enter.prevent.stop="!$event.isComposing && ($event.target as HTMLInputElement).blur()"
@keydown.esc.prevent.stop="!$event.isComposing && cancel($event.target as HTMLInputElement)"
>
{{ task.title.trim() }}
</h1>

View File

@ -53,6 +53,10 @@ export default function inputPrompt(pos: ClientRect, oldValue: string = ''): Pro
return
}
if (event.isComposing) {
return
}
const url = (event.target as HTMLInputElement).value
resolve(url)