Skip to content

Commit 51f1dd9

Browse files
committed
Merge PR #1227
2 parents a318108 + 42c2ded commit 51f1dd9

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
<!-- Feel free to put either your handle and/or full name, according to
22
your privacy needs -->
33

4+
* Allow the dropdown to reopen on click if it is closed without losing focus
5+
by closeAfterSelect: true
6+
7+
*@fishpercolator*
8+
9+
410
* Fixed bug making `clearOptions` function. Now it doesn't remove already selected options.
511

612
*(thanks @caseymct - #1079)*

src/selectize.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,9 @@ $.extend(Selectize.prototype, {
362362

363363
// necessary for mobile webkit devices (manual focus triggering
364364
// is ignored unless invoked within a click event)
365-
if (!self.isFocused) {
365+
// also necessary to reopen a dropdown that has been closed by
366+
// closeAfterSelect
367+
if (!self.isFocused || !self.isOpen) {
366368
self.focus();
367369
e.preventDefault();
368370
}

test/interaction.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,23 @@
4141
});
4242
});
4343
});
44+
45+
it('should reopen dropdown if clicked after being closed by closeAfterSelect: true', function(done) {
46+
var test = setup_test('<select multiple>' +
47+
'<option value="a">A</option>' +
48+
'<option value="b">B</option>' +
49+
'</select>', {closeAfterSelect: true});
50+
51+
click(test.selectize.$control, function() {
52+
click($('[data-value=a]', test.selectize.$dropdown_content), function() {
53+
click(test.selectize.$control, function () {
54+
expect(test.selectize.isOpen).to.be.equal(true);
55+
expect(test.selectize.isFocused).to.be.equal(true);
56+
done();
57+
});
58+
});
59+
});
60+
});
4461

4562
it('should close and blur dropdown after selection made if closeAfterSelect: true and in single mode' , function(done) {
4663
var test = setup_test('<select>' +

0 commit comments

Comments
 (0)