]> git.ipfire.org Git - thirdparty/foundation/foundation-sites.git/commitdiff
fix: prevent dropdownMenu to reopen after being closed on touch
authorNicolas Coden <nicolas@ncoden.fr>
Sun, 25 Mar 2018 17:32:52 +0000 (19:32 +0200)
committerNicolas Coden <nicolas@ncoden.fr>
Sun, 25 Mar 2018 17:45:02 +0000 (19:45 +0200)
When a dropdownMenu is closed by taping on its item, a timeout to open the dropdown on hover after a delay is still set, and the dropdown will reopen.

Changes:
* clean the active item `_delay` when the dropdownMenu is closed

js/foundation.dropdownMenu.js

index 6282cd2a26791d5984eade6df62afc715b28ddd4..a0be51143a2f3b44c8ccc699fd7e42da3d087dbb 100644 (file)
@@ -348,7 +348,8 @@ class DropdownMenu extends Plugin {
     var somethingToClose = $toClose.hasClass('is-active') || $toClose.find('.is-active').length > 0;
 
     if (somethingToClose) {
-      $toClose.find('li.is-active').add($toClose).attr({
+      var $activeItem = $toClose.find('li.is-active');
+      $activeItem.add($toClose).attr({
         'data-is-click': false
       }).removeClass('is-active');
 
@@ -361,6 +362,8 @@ class DropdownMenu extends Plugin {
                 .addClass(`opens-${oldClass}`);
         this.changed = false;
       }
+
+      clearTimeout($activeItem.data('_delay'));
       this._removeBodyHandler();
 
       /**