Commit 17a78cc6 authored by Lisa Seeto's avatar Lisa Seeto Committed by Robert Lyon

Bug 1824045: Tabbing throuh menus focuses on the other menus before getting to menu content

added new funcs to send focus to first item in newly opened menu, return focus to menu button when
menu is closed.

behatnotneeded

Change-Id: I51fb40f010ca128ca0ab0441ad4ae5c8f2842f2c
Signed-off-by: default avatarLisa Seeto <lisaseeto@catalyst.net.nz>
parent 75b1a1d2
......@@ -1123,14 +1123,53 @@ jQuery(function($) {
});
/**
* Wire up menu so that links with submenu but no url just toggle the child collapse
* Custom handling for the navigation accessibility
*/
jQuery(function($) {
/**
* Wire up menu so that links with submenu but no url just toggle the child collapse
*/
$('nav .menu-dropdown-toggle').on('click', function(e) {
e.stopPropagation();
e.preventDefault();
$(this).next().trigger('click');
});
/**
* Send focus to first menu item unless it's an element of a sub menu
* Closes menu and returns focus to menu button
*/
$('nav .navbar-collapse').on('shown.bs.collapse', function(e) {
var parent = $(this);
if (!$(e.target).hasClass('child-nav collapse show')) {
$(this).find('ul li:first a').focus();
}
// Return focus to menu button from last submenu button
$($(this).find('button.navbar-showchildren:last')).on('blur', function() {
if ($(this).hasClass('collapsed')) {
var id = $(parent).attr('id');
$('button[aria-controls="' + id + '"]').focus();
$(parent).collapse('hide');
}
});
// Return focus to menu button from last element in menu when tabbing away
$(this).find('ul li:last a').on('blur', function() {
var id = $(parent).attr('id');
$('button[aria-controls="' + id + '"]').focus();
$(parent).collapse('hide');
});
});
// Returns focus back to the menu button when the menu is closed
$('nav .navbar-collapse').on('hide.bs.collapse', function(e) {
if (!$(e.target).hasClass('child-nav collapse show')) {
var id = $(this).attr('id');
$('button[aria-controls=' + id + ']').focus();
}
});
});
function pmeter_success(form, data) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment