Skip to content

Commit

Permalink
MDL-70792 output: Menu items should have -1 tab index
Browse files Browse the repository at this point in the history
* As per WAI ARIA Authoring Practices 1.1 guidelines for menus,
menu items should have a tab index of -1. Navigation between menu items
is done via arrow keys.

See https://www.w3.org/TR/wai-aria-practices-1.1/#menu
  • Loading branch information
junpataleta committed Feb 24, 2022
1 parent 62a9021 commit ef132f0
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/outputcomponents.php
Expand Up @@ -4321,6 +4321,7 @@ public function add($action) {
public function add_primary_action($action) {
if ($action instanceof action_link || $action instanceof pix_icon) {
$action->attributes['role'] = 'menuitem';
$action->attributes['tabindex'] = '-1';
if ($action instanceof action_menu_link) {
$action->actionmenu = $this;
}
Expand All @@ -4336,6 +4337,7 @@ public function add_primary_action($action) {
public function add_secondary_action($action) {
if ($action instanceof action_link || $action instanceof pix_icon) {
$action->attributes['role'] = 'menuitem';
$action->attributes['tabindex'] = '-1';
if ($action instanceof action_menu_link) {
$action->actionmenu = $this;
}
Expand Down Expand Up @@ -4393,7 +4395,8 @@ public function get_primary_actions(core_renderer $output = null) {
'title' => $title,
'aria-label' => $label,
'id' => 'action-menu-toggle-'.$this->instance,
'role' => 'menuitem'
'role' => 'menuitem',
'tabindex' => '-1',
);
$link = html_writer::link('#', $string . $this->menutrigger . $pixicon, $attributes);
if ($this->prioritise) {
Expand Down

0 comments on commit ef132f0

Please sign in to comment.