'ARROW_DOWN': 'down',
'ARROW_LEFT': 'previous',
'ESCAPE': 'close',
- 'TAB': 'down',
- 'SHIFT_TAB': 'up'
});
}
$elem.attr('aria-expanded', true);
this.$currentMenu = $submenu;
- $submenu.addClass('is-active').removeClass('invisible').attr('aria-hidden', false);
+
+ //hide drilldown parent menu when submenu is open
+ // this removes it from the dom so that the tab key will take the user to the next visible element
+ $elem.parent().closest('ul').addClass('invisible');
+
+ // add visible class to submenu to override invisible class above
+ $submenu.addClass('is-active visible').removeClass('invisible').attr('aria-hidden', false);
+
if (this.options.autoHeight) {
this.$wrapper.css({ height: $submenu.data('calcHeight') });
}
_hide($elem) {
if(this.options.autoHeight) this.$wrapper.css({height:$elem.parent().closest('ul').data('calcHeight')});
var _this = this;
+ $elem.parent().closest('ul').removeClass('invisible');
$elem.parent('li').attr('aria-expanded', false);
$elem.attr('aria-hidden', true);
$elem.addClass('is-closing')
.one(transitionend($elem), function(){
- $elem.removeClass('is-active is-closing');
+ $elem.removeClass('is-active is-closing visible');
$elem.blur().addClass('invisible');
});
/**
$html.find('> li:nth-child(1) > ul').should.have.class('is-closing');
});
- it('moves focus to next element on TAB', function() {
- $html = $(template).appendTo('body');
- plugin = new Foundation.Drilldown($html, {});
-
- $html.find('> li:nth-child(1) > a').focus()
- .trigger(window.mockKeyboardEvent('TAB'));
-
- document.activeElement.should.be.equal($html.find('> li:nth-child(2) > a')[0]);
- });
- it('moves focus to previous element on TAB', function() {
- $html = $(template).appendTo('body');
- plugin = new Foundation.Drilldown($html, {});
-
- $html.find('> li:nth-child(2) > a').focus()
- .trigger(window.mockKeyboardEvent('TAB', {shift: true}));
-
- document.activeElement.should.be.equal($html.find('> li:nth-child(1) > a')[0]);
- });
it('moves focus to next element on ARROW_DOWN', function() {
$html = $(template).appendTo('body');
plugin = new Foundation.Drilldown($html, {});