Skip to content

Commit

Permalink
fix(select): open dropdown with arrow keys
Browse files Browse the repository at this point in the history
  • Loading branch information
hirsch committed Sep 29, 2021
1 parent eb15ff6 commit f1621dd
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions packages/components/src/components/bal-select/bal-select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ export class Select {
}

@Listen('keydown', { target: 'window' })
handleKeyDown(event: KeyboardEvent) {
async handleKeyDown(event: KeyboardEvent) {
if (this.isDropdownOpen) {
if (isArrowDownKey(event) || isArrowUpKey(event)) {
preventDefault(event)
Expand All @@ -199,6 +199,11 @@ export class Select {
if (isSpaceKey(event) && !this.typeahead) {
preventDefault(event)
}
} else {
if (isArrowDownKey(event) || isArrowUpKey(event)) {
preventDefault(event)
await this.open()
}
}
}

Expand Down Expand Up @@ -582,7 +587,7 @@ export class Select {
}

private handleKeyPress = async (event: KeyboardEvent) => {
if (isSpaceKey(event) && !this.isDropdownOpen) {
if (!this.isDropdownOpen && isSpaceKey(event)) {
preventDefault(event)
await this.open()
}
Expand Down

0 comments on commit f1621dd

Please sign in to comment.