]> git.ipfire.org Git - thirdparty/foundation/foundation-sites.git/commitdiff
Fixed toggling of ARIA attributes.
authorMarius Olbertz <marius.olbertz@gmail.com>
Wed, 5 Oct 2016 16:52:51 +0000 (18:52 +0200)
committerMarius Olbertz <marius.olbertz@gmail.com>
Wed, 5 Oct 2016 16:52:51 +0000 (18:52 +0200)
js/foundation.drilldown.js

index 71127b6a8af5965295745bb6cf56878124c70c7a..bcae853fdbce64dc378c9f1f3cc77cafb0c94421 100644 (file)
@@ -238,6 +238,12 @@ class Drilldown {
         e.stopImmediatePropagation();
         // console.log('mouseup on back');
         _this._hide($elem);
+
+        // If there is a parent submenu, call show
+        let parentSubMenu = $elem.parent('li').parent('ul').parent('li');
+        if (parentSubMenu.length) { 
+          _this._show(parentSubMenu);
+        }
       });
   }
 
@@ -265,7 +271,8 @@ class Drilldown {
    * @param {jQuery} $elem - the current element with a submenu to open, i.e. the `li` tag.
    */
   _show($elem) {
-    $elem.children('[data-submenu]').addClass('is-active');
+    $elem.attr('aria-expanded', true);
+    $elem.children('[data-submenu]').addClass('is-active').attr('aria-hidden', false);
     /**
      * Fires when the submenu has opened.
      * @event Drilldown#open
@@ -281,7 +288,8 @@ class Drilldown {
    */
   _hide($elem) {
     var _this = this;
-    $elem.addClass('is-closing')
+    $elem.parent('li').attr('aria-expanded', false);
+    $elem.attr('aria-hidden', true).addClass('is-closing')
          .one(Foundation.transitionend($elem), function(){
            $elem.removeClass('is-active is-closing');
            $elem.blur();