Skip to content

Commit

Permalink
Move 'title' attribute of NavMenu toggles to the <a> elements
Browse files Browse the repository at this point in the history
Currently, the 'title' attribute on a NavMenu section/item is placed on the
top-level wrapper <div> element, instead of the dropdown-toggle's <a>
element.  Everywhere else, 'title' attributes are placed directly on the
<a> element of the button/item/link.

Since the top-level wrapper <div> encompasses the menu as well as the toggle,
any items in the menu that do not have their own explicit 'title' attribute
will inherit the top-level title.  In other words, menu items that should
not have tooltips will get the same tooltip as the dropdown-toggle.

This commit moves the 'title' attribute in NavMenu off the top-level <div>
and onto the toggle <a> element.
  • Loading branch information
mdoggydog committed Oct 4, 2022
1 parent 8117b02 commit ac6a850
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Components/NavMenu.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,12 +155,12 @@ protected function buildDropdownMenuStub( $menuDescription ) {
return $this->indent() . \Html::rawElement( 'div',
[
'class' => 'nav-item ' . $menuId . '-dropdown',
'title' => Linker::titleAttrib( $menuId )
],
\Html::rawElement( 'a',
[
'href' => '#',
'class' => 'nav-link ' . $menuId . '-toggle',
'title' => Linker::titleAttrib( $menuId ),
],
htmlspecialchars( $menuDescription['header'] ) )
);
Expand All @@ -179,7 +179,6 @@ protected function buildDropdownOpeningTags( $menuDescription ) {
$ret = $this->indent() . \Html::openElement( 'div',
[
'class' => 'nav-item dropdown ' . $menuId . '-dropdown',
'title' => Linker::titleAttrib( $menuId ),
] );

// add the dropdown toggle
Expand All @@ -190,6 +189,7 @@ protected function buildDropdownOpeningTags( $menuDescription ) {
'class' => 'nav-link dropdown-toggle ' . $menuId . '-toggle',
'data-toggle' => 'dropdown',
'data-boundary' => 'viewport',
'title' => Linker::titleAttrib( $menuId ),
],
htmlspecialchars( $menuDescription['header'] ) );

Expand Down

0 comments on commit ac6a850

Please sign in to comment.