Skip to content

Commit 1ef750e

Browse files
author
Andrew Leach
committed
More PR feedback
1 parent 3995d9d commit 1ef750e

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

src/index.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ export default class Combobox {
6767
;(this.input as HTMLElement).addEventListener('keydown', this.keyboardEventHandler)
6868
this.list.addEventListener('click', commitWithElement)
6969
this.indicateDefaultOption()
70-
this.focusDefaultOptionIfNeeded()
7170
}
7271

7372
stop(): void {
@@ -85,11 +84,7 @@ export default class Combobox {
8584
Array.from(this.list.querySelectorAll<HTMLElement>('[role="option"]:not([aria-disabled="true"])'))
8685
.filter(visible)[0]
8786
?.setAttribute('data-combobox-option-default', 'true')
88-
}
89-
}
90-
91-
focusDefaultOptionIfNeeded(): void {
92-
if (this.firstOptionSelectionMode === 'selected') {
87+
} else if (this.firstOptionSelectionMode === 'selected') {
9388
this.navigate(1)
9489
}
9590
}
@@ -133,7 +128,10 @@ export default class Combobox {
133128
for (const el of this.list.querySelectorAll('[aria-selected="true"]')) {
134129
el.removeAttribute('aria-selected')
135130
}
136-
this.indicateDefaultOption()
131+
132+
if (this.firstOptionSelectionMode === 'active') {
133+
this.indicateDefaultOption()
134+
}
137135
}
138136
}
139137

0 commit comments

Comments
 (0)