Skip to content

Commit

Permalink
add separate open/close methods (#1893)
Browse files Browse the repository at this point in the history
  • Loading branch information
caseyjhol committed Aug 12, 2020
1 parent 13644fa commit 10041c4
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions js/bootstrap-select.js
Original file line number Diff line number Diff line change
Expand Up @@ -2966,12 +2966,28 @@
return this.changeAll(false);
},

toggle: function (e) {
toggle: function (e, state) {
var isActive,
triggerClick = state === undefined;

e = e || window.event;

if (e) e.stopPropagation();

this.$button.trigger('click.bs.dropdown.data-api');
if (triggerClick === false) {
isActive = this.$newElement[0].classList.contains(classNames.SHOW);
triggerClick = state === true && isActive === false || state === false && isActive === true;
}

if (triggerClick) this.$button.trigger('click.bs.dropdown.data-api');
},

open: function (e) {
this.toggle(e, true);
},

close: function (e) {
this.toggle(e, false);
},

keydown: function (e) {
Expand Down

0 comments on commit 10041c4

Please sign in to comment.