Skip to content

Commit bb9d53f

Browse files
Add automatic combobox item ID
1 parent ce22bbc commit bb9d53f

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

src/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,9 @@ export default class Combobox {
126126
el.removeAttribute('data-combobox-option-default')
127127

128128
if (target === el) {
129+
if (!target.id) {
130+
target.id = `combobox-item-${Math.random().toString().slice(2, 6)}`
131+
}
129132
this.input.setAttribute('aria-activedescendant', target.id)
130133
target.setAttribute('aria-selected', 'true')
131134
fireSelectEvent(target)

0 commit comments

Comments
 (0)