Skip to content

Commit c9aae48

Browse files
committed
Fix Combobox
- Listen to mousedown instead of mouseup to select option (the previous implementation was hiding the options in dialogs because the dialog got focused during mousedown, triggering handleDocumentFocusIn). - Reset filter when options are hidden, in order to improve the UX when the list is open again.
1 parent bb0b83a commit c9aae48

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

src/components/combobox/Combobox.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ export default class Combobox extends WebComponent {
132132
aria-labelledby=${this.label ? this.inputTrait.labelId : nothing}
133133
aria-label=${this.label ? nothing : accessibleName}
134134
?hidden=${!this.open}
135-
@mouseup=${this.onListboxMouseUp}
135+
@mousedown=${this.onListboxMouseDown}
136136
>
137137
${options.map(
138138
(option, index) =>
@@ -225,6 +225,7 @@ export default class Combobox extends WebComponent {
225225
return
226226
}
227227

228+
this.filter = ''
228229
this.open = false
229230
this.activeIndex = -1
230231
this.removeOpenListeners()
@@ -358,7 +359,9 @@ export default class Combobox extends WebComponent {
358359
}
359360
}
360361

361-
private onListboxMouseUp (event: MouseEvent) {
362+
private onListboxMouseDown (event: MouseEvent) {
363+
event.preventDefault()
364+
362365
if (!(event.target instanceof HTMLElement)) {
363366
return
364367
}

0 commit comments

Comments
 (0)