diff --git a/blocks/site_main_menu/block_site_main_menu.php b/blocks/site_main_menu/block_site_main_menu.php index d0d938d0224..cd26cbc918b 100644 --- a/blocks/site_main_menu/block_site_main_menu.php +++ b/blocks/site_main_menu/block_site_main_menu.php @@ -73,8 +73,9 @@ class block_site_main_menu extends block_list { $attrs['title'] = $cm->modfullname; $attrs['class'] = $cm->extraclasses . ' activity-action'; if ($cm->onclick) { - $attrs['id'] = html_writer::random_id('onclick'); - $OUTPUT->add_action_handler(new component_action('click', $cm->onclick), $attrs['id']); + // Get on-click attribute value if specified and decode the onclick - it + // has already been encoded for display. + $attrs['onclick'] = htmlspecialchars_decode($cm->onclick); } if (!$cm->visible) { $attrs['class'] .= ' dimmed'; @@ -161,8 +162,9 @@ class block_site_main_menu extends block_list { $attrs['title'] = $mod->modfullname; $attrs['class'] = $mod->extraclasses . ' activity-action'; if ($mod->onclick) { - $attrs['id'] = html_writer::random_id('onclick'); - $OUTPUT->add_action_handler(new component_action('click', $mod->onclick), $attrs['id']); + // Get on-click attribute value if specified and decode the onclick - it + // has already been encoded for display. + $attrs['onclick'] = htmlspecialchars_decode($mod->onclick); } if (!$mod->visible) { $attrs['class'] .= ' dimmed'; diff --git a/blocks/site_main_menu/tests/behat/add_url.feature b/blocks/site_main_menu/tests/behat/add_url.feature new file mode 100644 index 00000000000..f391d7bc6f1 --- /dev/null +++ b/blocks/site_main_menu/tests/behat/add_url.feature @@ -0,0 +1,18 @@ +@block @block_main_menu +Feature: Add URL to main menu block + In order to add helpful resources for students + As a admin + I need to add URLs to the main menu block and check it works. + + @javascript + Scenario: Add a URL in menu block and ensure it appears + Given I log in as "admin" + And I am on site homepage + And I navigate to "Turn editing on" node in "Front page settings" + When I add a "URL" to section "0" and I fill the form with: + | Name | google | + | Description | gooooooooogle | + | External URL | http://www.google.com | + | id_display | In pop-up | + Then "google" "link" should exist in the "Main menu" "block" + And "Add an activity or resource" "link" should exist in the "Main menu" "block"