From 8fdbe51387f25fc79fbf23dba1bbcddefd62e2ee Mon Sep 17 00:00:00 2001 From: Nicolas Coden Date: Sun, 25 Mar 2018 19:32:52 +0200 Subject: [PATCH] fix: prevent dropdownMenu to reopen after being closed on touch 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 | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/js/foundation.dropdownMenu.js b/js/foundation.dropdownMenu.js index 6282cd2a2..a0be51143 100644 --- a/js/foundation.dropdownMenu.js +++ b/js/foundation.dropdownMenu.js @@ -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(); /** -- 2.47.2