]> git.ipfire.org Git - thirdparty/foundation/foundation-sites.git/commitdiff
Resolves issue#10657 (When closeOnClick option is true, clicking on the dropdown... 10658/head
authorBhupinder Singh <bhupinderbola@netscape.net>
Mon, 18 Sep 2017 01:55:00 +0000 (21:55 -0400)
committerBhupinder Singh <bhupinderbola@netscape.net>
Mon, 18 Sep 2017 01:55:00 +0000 (21:55 -0400)
js/foundation.dropdown.js
test/javascript/components/dropdown.js

index ed054feeceff92ad24f3205169c7fcc399b0cc4a..f1da4c5411199121b7ce76f21124ca55172e1560 100644 (file)
@@ -205,7 +205,7 @@ class Dropdown extends Positionable {
             if(_this.$anchors.is(e.target) || _this.$anchors.find(e.target).length) {
               return;
             }
-            if(_this.$element.find(e.target).length) {
+            if(_this.$element.is(e.target) || _this.$element.find(e.target).length) {
               return;
             }
             _this.close();
index 6a7e029fc5b7166c9fa1a7255baca247315bb00c..608ce0087969acbd60185adc0b3a9744d8f72df5 100644 (file)
@@ -77,4 +77,24 @@ describe('Dropdown', function() {
       plugin.alignment.should.equal('right')
     });
   });
+
+  describe('closeOnClick option', function() {
+    it('not closes a dropdown by clicking on the dropdown if closeOnClick option is true', function(done) {
+      $dropdownController = $(getDropdownController()).appendTo('body');
+      $dropdownContainer = $(getDropdownContainer()).appendTo('body');
+      plugin = new Foundation.Dropdown($dropdownContainer, {closeOnClick: true});
+
+      // Open it first...
+      plugin.open();
+
+      let spy = sinon.spy(plugin, 'close');
+
+      plugin.$element.trigger("click");
+
+      setTimeout(function() {
+        sinon.assert.notCalled(spy);
+        done();
+      }, 2);
+    });
+  });
 });