From 5332bde69b63675d22c256c034a22c471c42f46e Mon Sep 17 00:00:00 2001 From: Bhupinder Singh Date: Sun, 17 Sep 2017 21:55:00 -0400 Subject: [PATCH] Resolves issue#10657 (When closeOnClick option is true, clicking on the dropdown element should not close it.) --- js/foundation.dropdown.js | 2 +- test/javascript/components/dropdown.js | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) 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); + }); + }); }); -- 2.47.2