From 4af179d65a2f03e93c0f1213279f8b630b1d7f89 Mon Sep 17 00:00:00 2001 From: Prasanna LMSACE Date: Sat, 27 Apr 2024 15:38:55 +0530 Subject: [PATCH] BugFix: Tab-Index for Smart Menus, resolves #619 --- lang/en/theme_boost_union.php | 3 ++ layout/includes/smartmenus.php | 4 +++ settings.php | 7 ++++ .../smartmenus-cardmenu-children.mustache | 18 ++++++---- .../smartmenus-moremenu-children.mustache | 20 +++++++---- ...oost_union_feelsettings_navigation.feature | 35 +++++++++++++++++++ version.php | 2 +- 7 files changed, 74 insertions(+), 15 deletions(-) diff --git a/lang/en/theme_boost_union.php b/lang/en/theme_boost_union.php index 009c0d17ace..0168120791d 100644 --- a/lang/en/theme_boost_union.php +++ b/lang/en/theme_boost_union.php @@ -421,6 +421,9 @@ $string['shownavbarstarredcoursessetting_desc'] = 'With this setting, you can show a popover menu with links to starred courses next to the messages and notifications menus.'; $string['shownavbarstarredcourses_config'] = 'Set starred courses on the \'My courses\' page'; $string['shownavbarstarredcourses_label'] = 'Starred courses'; +// ... ... Setting: Allow tab index for primary menus. +$string['allowmenustabindexsetting'] = 'Allow tab index for primary menus'; +$string['allowmenustabindexsetting_desc'] = 'This configuration allows enabling or disabling the use of tab index for primary menus. When enabled, tab index will be assigned to primary menu items, allowing keyboard navigation through the menus. If disabled, tab index will not be assigned to primary menu items, preventing keyboard navigation.'; // ... Section: Breadcrumbs. $string['breadcrumbsheading'] = 'Breadcrumbs'; // ... ... Setting: Course category breadcrumb. diff --git a/layout/includes/smartmenus.php b/layout/includes/smartmenus.php index 1a265be8938..14b232fb453 100644 --- a/layout/includes/smartmenus.php +++ b/layout/includes/smartmenus.php @@ -31,3 +31,7 @@ // Add smart menu flag if the smart menu contains any menus to show. $includesmartmenu = (isset($primarymenu['includesmartmenu']) && !empty($primarymenu['includesmartmenu'])); $templatecontext['includesmartmenu'] = $includesmartmenu ? true : false; + +// Allow tab index for the primary menus. +$tabindex = get_config('theme_boost_union', 'allowmenustabindex'); +$templatecontext['allowmenustabindex'] = (bool) ($tabindex == THEME_BOOST_UNION_SETTING_SELECT_YES); diff --git a/settings.php b/settings.php index 70cfb67d6b8..34383bc7dc7 100644 --- a/settings.php +++ b/settings.php @@ -1290,6 +1290,13 @@ $setting->set_updatedcallback('theme_reset_all_caches'); $tab->add($setting); + // Setting: Allow tab index for the primary menus. + $name = 'theme_boost_union/allowmenustabindex'; + $title = get_string('allowmenustabindexsetting', 'theme_boost_union', null, true); + $description = get_string('allowmenustabindexsetting_desc', 'theme_boost_union', null, true); + $setting = new admin_setting_configselect($name, $title, $description, THEME_BOOST_UNION_SETTING_SELECT_NO, $yesnooption); + $tab->add($setting); + // Create breadcrumbs heading. $name = 'theme_boost_union/breadcrumbsheading'; $title = get_string('breadcrumbsheading', 'theme_boost_union', null, true); diff --git a/templates/smartmenus-cardmenu-children.mustache b/templates/smartmenus-cardmenu-children.mustache index cbfd42bc969..0441131f804 100644 --- a/templates/smartmenus-cardmenu-children.mustache +++ b/templates/smartmenus-cardmenu-children.mustache @@ -20,6 +20,10 @@ The smart menus card menu children. This is a modified version of core/moremenu_children. + Modifications compared to the original template: + * Added tabindex attribute to the card-item-overlay and card-image wrapper link tags to prevent tab navigation. + * Added tabindex condition to enable tab navigation across menu items. + Example context (json): { "divider": "", @@ -36,7 +40,7 @@ @@ -48,23 +52,23 @@ {{#children}} {{^divider}}
- +
- +
{{^is_action_link}} - {{{text}}} + {{{text}}} {{/is_action_link}}
{{^is_action_link}} @@ -89,7 +93,7 @@ @@ -102,7 +106,7 @@ diff --git a/templates/smartmenus-moremenu-children.mustache b/templates/smartmenus-moremenu-children.mustache index 8d4d5eab6c3..d61787e54f7 100644 --- a/templates/smartmenus-moremenu-children.mustache +++ b/templates/smartmenus-moremenu-children.mustache @@ -20,6 +20,9 @@ The smart menus more menu children. This is a modified version of core/moremenu_children. + Modifications compared to the original template: + * Added tabindex condition within the dropdown-items and nav-link link elements to enable tab navigation across menu items. + Example context (json): { "divider": "", @@ -38,7 +41,7 @@ {{#tooltip}}title="{{.}}" data-toggle="tooltip"{{/tooltip}}{{^tooltip}}{{#title}}title="{{.}}"{{/title}}{{/tooltip}} {{#attributes}}{{name}}="{{value}}" {{/attributes}} {{#isactive}}aria-current="true"{{/isactive}} - {{^isactive}}tabindex="-1"{{/isactive}} + {{^allowmenustabindex}}{{^isactive}}tabindex="-1"{{/isactive}}{{/allowmenustabindex}} > {{{text}}} @@ -54,7 +57,7 @@ {{{text}}} @@ -63,7 +66,8 @@ {{/action_link_actions}} {{/is_action_link}} {{^is_action_link}} - @@ -91,7 +95,8 @@