MDL-66849 output: Remove custom menu title when not specified
authorMichael Milette <michael.milette@tngconsulting.ca>
Wed, 12 Feb 2020 15:37:25 +0000 (10:37 -0500)
committerMichael Milette <michael.milette@tngconsulting.ca>
Wed, 15 Apr 2020 02:27:06 +0000 (22:27 -0400)
lib/outputcomponents.php
lib/templates/custom_menu_item.mustache
lib/tests/outputcomponents_test.php

index fa9a76f..ab3f3e4 100644 (file)
@@ -3763,11 +3763,10 @@ class custom_menu extends custom_menu_item {
                 $setting = trim($setting);
                 if (!empty($setting)) {
                     switch ($i) {
                 $setting = trim($setting);
                 if (!empty($setting)) {
                     switch ($i) {
-                        case 0:
+                        case 0: // Menu text.
                             $itemtext = ltrim($setting, '-');
                             $itemtext = ltrim($setting, '-');
-                            $itemtitle = $itemtext;
                             break;
                             break;
-                        case 1:
+                        case 1: // URL.
                             try {
                                 $itemurl = new moodle_url($setting);
                             } catch (moodle_exception $exception) {
                             try {
                                 $itemurl = new moodle_url($setting);
                             } catch (moodle_exception $exception) {
@@ -3776,10 +3775,10 @@ class custom_menu extends custom_menu_item {
                                 $itemurl = null;
                             }
                             break;
                                 $itemurl = null;
                             }
                             break;
-                        case 2:
+                        case 2: // Title attribute.
                             $itemtitle = $setting;
                             break;
                             $itemtitle = $setting;
                             break;
-                        case 3:
+                        case 3: // Language.
                             if (!empty($language)) {
                                 $itemlanguages = array_map('trim', explode(',', $setting));
                                 $itemvisible &= in_array($language, $itemlanguages);
                             if (!empty($language)) {
                                 $itemlanguages = array_map('trim', explode(',', $setting));
                                 $itemvisible &= in_array($language, $itemlanguages);
index 42f1fbc..544d081 100644 (file)
@@ -33,7 +33,7 @@
 {{^divider}}
 {{#haschildren}}
 <li class="dropdown nav-item">
 {{^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}}">
         {{{text}}}
     </a>
     <div class="dropdown-menu" role="menu" id="drop-down-menu-{{uniqid}}" aria-labelledby="drop-down-{{uniqid}}">
index b782f11..0a631aa 100644 (file)
@@ -321,7 +321,7 @@ EOF;
         $itemurl = $item->get_url();
         $this->assertTrue($itemurl instanceof moodle_url);
         $this->assertEquals('http://moodle.org', $itemurl->out());
         $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);
 
         /** @var custom_menu_item $item */
         $item = array_shift($firstlevel);