]> git.ipfire.org Git - thirdparty/foundation/foundation-sites.git/commitdiff
Use pull request #11411 from arloduff/fix/check-for-null-related-target for v6.5.0
authorArlo Duff <arlo.duff@shoes.com>
Sat, 25 Aug 2018 20:33:39 +0000 (22:33 +0200)
committerNicolas Coden <nicolas@ncoden.fr>
Sat, 25 Aug 2018 20:33:39 +0000 (22:33 +0200)
ac88dac72 fix: resolve dropdown menu disappearing for #11410
ae8fa2def fix: move relatedTarget null check to setTimeout for #11410
a25180c3d style: improve dropdown hiding event readability in dropdownMenu
e46ddd1cc docs: improve description of #11410 bug fix in dropdownMenu
ebc4be784 docs: fix typo in bug description in dropdownMenu

Co-Authored-By: Nicolas Coden <nicolas@ncoden.fr>
Signed-off-by: Nicolas Coden <nicolas@ncoden.fr>
js/foundation.dropdownMenu.js

index 2d9bb2cf046090069d06550357da10750b4ceb39..dc9fb57ba73760873bf848333254864134b70f61 100644 (file)
@@ -152,9 +152,20 @@ class DropdownMenu extends Plugin {
           if ($elem.attr('data-is-click') === 'true' && _this.options.clickOpen) { return false; }
 
           clearTimeout($elem.data('_delay'));
-          $elem.data('_delay', setTimeout(function() {
+          $elem.data('_delay', setTimeout(function () {
+
+            // Ignore "magic mouseleave": when the mouse simply disapear from the document
+            // (like when entering in browser input suggestions See https://git.io/zf-11410),
+            // unless we actually left the window (and document lost focus).
+            //
+            // In firefox, document will not focus at the time the event is triggered, so we have
+            // to make this test after the delay.
+            if (e.relatedTarget === null && document.hasFocus && document.hasFocus()) { return false; }
+
             _this._hide($elem);
+
           }, _this.options.closingTime));
+
         }
       });
     }