Skip to content

Commit 0c3c174

Browse files
authored
fix(Listbox): avoid blocking specific keydown events (#2148)
1 parent 0b0e7cb commit 0c3c174

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

packages/core/src/Listbox/ListboxContent.vue

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,23 @@ const isClickFocus = refAutoReset(false, 10)
3434
return
3535
rootContext.onEnter(ev)
3636
}"
37-
@keydown.down.up.left.right.home.end.prevent="(event) => {
37+
@keydown.down.up.left.right.home.end="(event: KeyboardEvent) => {
38+
if (
39+
// when orientation is vertical, ignore left/right
40+
(
41+
rootContext.orientation.value === 'vertical'
42+
&& (event.key === 'ArrowLeft' || event.key === 'ArrowRight')
43+
)
44+
// when orientation is horizontal, ignore up/down
45+
|| (
46+
rootContext.orientation.value === 'horizontal'
47+
&& (event.key === 'ArrowUp' || event.key === 'ArrowDown')
48+
)
49+
) {
50+
return
51+
}
52+
53+
event.preventDefault()
3854
rootContext.focusable.value ? rootContext.onKeydownNavigation(event) : undefined
3955
}"
4056
@keydown.enter="rootContext.onKeydownEnter"

0 commit comments

Comments
 (0)