From: Bhupinder Singh Date: Mon, 18 Sep 2017 01:55:00 +0000 (-0400) Subject: Resolves issue#10657 (When closeOnClick option is true, clicking on the dropdown... X-Git-Tag: v6.4.4-rc1~7^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5332bde69b63675d22c256c034a22c471c42f46e;p=thirdparty%2Ffoundation%2Ffoundation-sites.git Resolves issue#10657 (When closeOnClick option is true, clicking on the dropdown element should not close it.) --- diff --git a/js/foundation.dropdown.js b/js/foundation.dropdown.js index ed054feec..f1da4c541 100644 --- a/js/foundation.dropdown.js +++ b/js/foundation.dropdown.js @@ -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(); diff --git a/test/javascript/components/dropdown.js b/test/javascript/components/dropdown.js index 6a7e029fc..608ce0087 100644 --- a/test/javascript/components/dropdown.js +++ b/test/javascript/components/dropdown.js @@ -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); + }); + }); });