File tree Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -29,10 +29,14 @@ function attachOneDropdownAria($dropdown) {
29
29
const $focusable = $textSearch . length ? $textSearch : $dropdown ; // the primary element for focus, see comment above
30
30
if ( ! $focusable . length ) return ;
31
31
32
- // There are 2 possible solutions about the role: combobox or menu. Always use combobox in the future, see "aria.md" for details.
33
- const focusableRole = 'button' ;
34
- const listPopupRole = 'menu' ;
35
- const listItemRole = 'menuitem' ;
32
+ // There are 2 possible solutions about the role: combobox or menu.
33
+ // The idea is that if there is an input, then it's a combobox, otherwise it's a menu.
34
+ // Since #19861 we have prepared the "combobox" solution, but didn't get enough time to put it into practice and test before.
35
+ const isComboBox = $dropdown . find ( 'input' ) . length > 0 ;
36
+
37
+ const focusableRole = isComboBox ? 'combobox' : 'button' ;
38
+ const listPopupRole = isComboBox ? 'listbox' : 'menu' ;
39
+ const listItemRole = isComboBox ? 'option' : 'menuitem' ;
36
40
37
41
// make the item has role=option/menuitem, and add an id if there wasn't one yet.
38
42
function prepareMenuItem ( $item ) {
You can’t perform that action at this time.
0 commit comments