Skip to content

Commit 3c65963

Browse files
dgrahammuan
andcommitted
Clear all selected items
Fixes cases where more than one item is marked as selected. This state shouldn't be possible inside combobox-nav but might happen in the host application. Co-authored-by: Mu-An Chiou <[email protected]>
1 parent b2933b7 commit 3c65963

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

combobox-nav.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,9 @@ export function navigate(
111111

112112
export function clearSelection(input: HTMLTextAreaElement | HTMLInputElement, list: HTMLElement): void {
113113
input.removeAttribute('aria-activedescendant')
114-
const target = list.querySelector('[aria-selected="true"]')
115-
if (!target) return
116-
target.setAttribute('aria-selected', 'false')
114+
for (const el of list.querySelectorAll('[aria-selected="true"]')) {
115+
el.setAttribute('aria-selected', 'false')
116+
}
117117
}
118118

119119
function trackComposition(event: Event): void {

0 commit comments

Comments
 (0)