Skip to content

Commit

Permalink
MDL-66849 output: Remove custom menu title when not specified
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-milette committed Apr 15, 2020
1 parent df0e58a commit 8056397
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
9 changes: 4 additions & 5 deletions lib/outputcomponents.php
Original file line number Diff line number Diff line change
Expand Up @@ -3763,11 +3763,10 @@ public static function convert_text_to_menu_nodes($text, $language = null) {
$setting = trim($setting);
if (!empty($setting)) {
switch ($i) {
case 0:
case 0: // Menu text.
$itemtext = ltrim($setting, '-');
$itemtitle = $itemtext;
break;
case 1:
case 1: // URL.
try {
$itemurl = new moodle_url($setting);
} catch (moodle_exception $exception) {
Expand All @@ -3776,10 +3775,10 @@ public static function convert_text_to_menu_nodes($text, $language = null) {
$itemurl = null;
}
break;
case 2:
case 2: // Title attribute.
$itemtitle = $setting;
break;
case 3:
case 3: // Language.
if (!empty($language)) {
$itemlanguages = array_map('trim', explode(',', $setting));
$itemvisible &= in_array($language, $itemlanguages);
Expand Down
2 changes: 1 addition & 1 deletion lib/templates/custom_menu_item.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
{{^divider}}
{{#haschildren}}
<li class="dropdown nav-item">
<a class="dropdown-toggle nav-link" id="drop-down-{{uniqid}}" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" href="#" aria-controls="drop-down-menu-{{uniqid}}">
<a class="dropdown-toggle nav-link" id="drop-down-{{uniqid}}" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" href="#" {{#title}}title="{{{title}}}"{{/title}} aria-controls="drop-down-menu-{{uniqid}}">
{{{text}}}
</a>
<div class="dropdown-menu" role="menu" id="drop-down-menu-{{uniqid}}" aria-labelledby="drop-down-{{uniqid}}">
Expand Down
2 changes: 1 addition & 1 deletion lib/tests/outputcomponents_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ public function test_basic_syntax() {
$itemurl = $item->get_url();
$this->assertTrue($itemurl instanceof moodle_url);
$this->assertEquals('http://moodle.org', $itemurl->out());
$this->assertEquals($item->get_text(), $item->get_title()); // Implicit title.
$this->assertNull($item->get_title()); // Implicit title.

/** @var custom_menu_item $item */
$item = array_shift($firstlevel);
Expand Down

0 comments on commit 8056397

Please sign in to comment.