fix(ui): prevent Enter key action during IME composition (#9564)
This commit is contained in:
@@ -133,7 +133,7 @@ export function List<T>(props: ListProps<T> & { ref?: (ref: ListRef) => void })
|
|||||||
const index = selected ? all.indexOf(selected) : -1
|
const index = selected ? all.indexOf(selected) : -1
|
||||||
props.onKeyEvent?.(e, selected)
|
props.onKeyEvent?.(e, selected)
|
||||||
|
|
||||||
if (e.key === "Enter") {
|
if (e.key === "Enter" && !e.isComposing) {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
if (selected) handleSelect(selected, index)
|
if (selected) handleSelect(selected, index)
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ export function useFilteredList<T>(props: FilteredListProps<T>) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const onKeyDown = (event: KeyboardEvent) => {
|
const onKeyDown = (event: KeyboardEvent) => {
|
||||||
if (event.key === "Enter") {
|
if (event.key === "Enter" && !event.isComposing) {
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
const selectedIndex = flat().findIndex((x) => props.key(x) === list.active())
|
const selectedIndex = flat().findIndex((x) => props.key(x) === list.active())
|
||||||
const selected = flat()[selectedIndex]
|
const selected = flat()[selectedIndex]
|
||||||
|
|||||||
Reference in New Issue
Block a user