Skip to content

Commit

Permalink
More PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
anleac committed Feb 22, 2024
1 parent 3995d9d commit 1ef750e
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ export default class Combobox {
;(this.input as HTMLElement).addEventListener('keydown', this.keyboardEventHandler)
this.list.addEventListener('click', commitWithElement)
this.indicateDefaultOption()
this.focusDefaultOptionIfNeeded()
}

stop(): void {
Expand All @@ -85,11 +84,7 @@ export default class Combobox {
Array.from(this.list.querySelectorAll<HTMLElement>('[role="option"]:not([aria-disabled="true"])'))
.filter(visible)[0]
?.setAttribute('data-combobox-option-default', 'true')
}
}

focusDefaultOptionIfNeeded(): void {
if (this.firstOptionSelectionMode === 'selected') {
} else if (this.firstOptionSelectionMode === 'selected') {
this.navigate(1)
}
}
Expand Down Expand Up @@ -133,7 +128,10 @@ export default class Combobox {
for (const el of this.list.querySelectorAll('[aria-selected="true"]')) {
el.removeAttribute('aria-selected')
}
this.indicateDefaultOption()

if (this.firstOptionSelectionMode === 'active') {
this.indicateDefaultOption()
}
}
}

Expand Down

0 comments on commit 1ef750e

Please sign in to comment.