Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewrite menu from scratch to support mobile sized screens and keyboard controls #175

Merged
merged 8 commits into from
Oct 13, 2020
Prev Previous commit
Next Next commit
Handle tab in dropdown item
  • Loading branch information
Giwayume committed Oct 12, 2020
commit fb91088a7e389c247f4ffcc47fb3bae3703b82b5
6 changes: 5 additions & 1 deletion src/js/core/gui/gui-menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class GUI_menu_class {
} else {
return `
<li>
<a id="main_menu_${ level }_${ index }" role="menuitem" aria-haspopup="${ (!!definition.children) + '' }"
<a id="main_menu_${ level }_${ index }" role="menuitem" tabindex="-1" aria-haspopup="${ (!!definition.children) + '' }"
href="${ definition.href ? definition.href : 'javascript:void(0)' }"
target="${ definition.href ? '_blank' : '_self' }"
data-level="${ level }" data-index="${ index }">
Expand Down Expand Up @@ -203,6 +203,9 @@ class GUI_menu_class {
opener.click();
opener.focus();
}
else if (event.key === 'Tab') {
this.close_child_dropdowns(0);
}
}
}
}
Expand Down Expand Up @@ -292,6 +295,7 @@ class GUI_menu_class {
let dropdownElement = document.createElement('ul');
dropdownElement.className = 'menu_dropdown';
dropdownElement.role = 'menu';
dropdownElement.tabIndex = 0;
dropdownElement.setAttribute('aria-labelledby', 'main_menu_' + level + '_' + index);
let dropdownTemplate = '';
for (let i = 0; i < children.length; i++) {
Expand Down