fix can't open dropdown with keyboard (#610)

This commit is contained in:
Lyu, Wei-Da 2021-04-24 09:35:18 +08:00 committed by GitHub
commit b810404afa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -203,7 +203,11 @@
tabindex="0" tabindex="0"
role="button" role="button"
aria-expanded="{open}" aria-expanded="{open}"
on:keydown="{({ key }) => { on:keydown="{(e) => {
const { key } = e;
if (['Enter', 'ArrowDown', 'ArrowUp'].includes(key)) {
e.preventDefault();
}
if (key === 'Enter') { if (key === 'Enter') {
open = !open; open = !open;
if (highlightedIndex > -1 && highlightedIndex !== selectedIndex) { if (highlightedIndex > -1 && highlightedIndex !== selectedIndex) {