Skip to content

Commit b4701a3

Browse files
committed
refactor(Autocomplete): improve accessibility handling
1 parent 1d3aef3 commit b4701a3

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

js/src/autocomplete.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -661,6 +661,7 @@ class Autocomplete extends BaseComponent {
661661
dropdownDiv.classList.add(CLASS_NAME_DROPDOWN)
662662
dropdownDiv.role = 'listbox'
663663
dropdownDiv.setAttribute('aria-labelledby', this._uniqueId)
664+
dropdownDiv.setAttribute('id', `${this._uniqueId}-listbox`)
664665

665666
const optionsDiv = document.createElement('div')
666667
optionsDiv.classList.add(CLASS_NAME_OPTIONS)
@@ -674,6 +675,8 @@ class Autocomplete extends BaseComponent {
674675

675676
const { container } = this._config
676677
if (container) {
678+
this._inputElement.setAttribute('aria-owns', `${this._uniqueId}-listbox`)
679+
dropdownDiv.id = `${this._uniqueId}-listbox`
677680
container.append(dropdownDiv)
678681
} else {
679682
this._element.append(dropdownDiv)

0 commit comments

Comments
 (0)