Skip to content

Commit d16014c

Browse files
author
Dmytro Poperechnyy
committed
MAGETWO-34477: Backend Menu Accessibility improvements
1 parent cdc3d60 commit d16014c

File tree

1 file changed

+27
-14
lines changed

1 file changed

+27
-14
lines changed

app/code/Magento/Backend/Block/Menu.php

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -210,16 +210,24 @@ protected function _renderItemCssClass($menuItem, $level)
210210
*/
211211
protected function _renderAnchor($menuItem, $level)
212212
{
213-
return '<a href="' . $menuItem->getUrl() . '" ' . $this->_renderItemAnchorTitle(
214-
$menuItem
215-
) . $this->_renderItemOnclickFunction(
216-
$menuItem
217-
) . ' class="' . $this->_renderAnchorCssClass(
218-
$menuItem,
219-
$level
220-
) . '">' . '<span>' . $this->_getAnchorLabel(
221-
$menuItem
222-
) . '</span>' . '</a>';
213+
if ($level == 1 && $menuItem->getUrl() == '#') {
214+
$output = '<strong class="submenu-group-title" role="presentation">'
215+
. '<span>' . $this->_getAnchorLabel($menuItem) . '</span>'
216+
. '</strong>';
217+
} else {
218+
$output = '<a href="' . $menuItem->getUrl() . '" ' . $this->_renderItemAnchorTitle(
219+
$menuItem
220+
) . $this->_renderItemOnclickFunction(
221+
$menuItem
222+
) . ' class="' . $this->_renderAnchorCssClass(
223+
$menuItem,
224+
$level
225+
) . '">' . '<span>' . $this->_getAnchorLabel(
226+
$menuItem
227+
) . '</span>' . '</a>';
228+
}
229+
230+
return $output;
223231
}
224232

225233
/**
@@ -397,15 +405,16 @@ protected function _columnBrake($items, $limit)
397405
* @param \Magento\Backend\Model\Menu\Item $menuItem
398406
* @param int $level
399407
* @param int $limit
408+
* @param $id int
400409
* @return string HTML code
401410
*/
402-
protected function _addSubMenu($menuItem, $level, $limit)
411+
protected function _addSubMenu($menuItem, $level, $limit, $id = null)
403412
{
404413
$output = '';
405414
if (!$menuItem->hasChildren()) {
406415
return $output;
407416
}
408-
$output .= '<div class="submenu">';
417+
$output .= '<div class="submenu"' . ($level == 0 && isset($id) ? ' aria-labelledby="' . $id . '"' : '') . '>';
409418
$colStops = null;
410419
if ($level == 0 && $limit) {
411420
$colStops = $this->_columnBrake($menuItem->getChildren(), $limit);
@@ -440,18 +449,22 @@ public function renderNavigation($menu, $level = 0, $limit = 0, $colBrakes = [])
440449
$output .= '</ul></li><li class="column"><ul>';
441450
}
442451

452+
$id = uniqid();
443453
$output .= '<li ' . $this->getUiId(
444454
$menuItem->getId()
445455
) . ' class="item-' . $itemClass . ' ' . $this->_renderItemCssClass(
446456
$menuItem,
447457
$level
448-
) . '">' . $this->_renderAnchor(
458+
) . ($level == 0 ? '" id="' . $id . '" aria-haspopup="true' : '')
459+
. '">'
460+
. $this->_renderAnchor(
449461
$menuItem,
450462
$level
451463
) . $this->_addSubMenu(
452464
$menuItem,
453465
$level,
454-
$limit
466+
$limit,
467+
$id
455468
) . '</li>';
456469
$itemPosition++;
457470
}

0 commit comments

Comments
 (0)