Skip to content

Commit cb2c573

Browse files
committed
implement the combobox layout suggested by go-gitea#19861
1 parent f1484ee commit cb2c573

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

web_src/js/features/aria.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,14 @@ function attachOneDropdownAria($dropdown) {
2929
const $focusable = $textSearch.length ? $textSearch : $dropdown; // the primary element for focus, see comment above
3030
if (!$focusable.length) return;
3131

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';
3640

3741
// make the item has role=option/menuitem, and add an id if there wasn't one yet.
3842
function prepareMenuItem($item) {

0 commit comments

Comments
 (0)