Skip to content

Commit

Permalink
remove Bootstrap keydown event listeners and re-add for non bootstrap…
Browse files Browse the repository at this point in the history
…-select selectors. $.off requires the selector matches exactly so the previous method didn't work. (#2308)
  • Loading branch information
caseyjhol committed Apr 16, 2020
1 parent a5b0752 commit 1ff4261
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion js/bootstrap-select.js
Original file line number Diff line number Diff line change
Expand Up @@ -3125,8 +3125,13 @@
return this;
};

// get Bootstrap's keydown event handler for either Bootstrap 4 or Bootstrap 3
var bootstrapKeydown = $.fn.dropdown.Constructor._dataApiKeydownHandler || $.fn.dropdown.Constructor.prototype.keydown;

$(document)
.off('keydown.bs.dropdown.data-api', '.bootstrap-select [data-toggle="dropdown"], .bootstrap-select .dropdown-menu')
.off('keydown.bs.dropdown.data-api')
.on('keydown.bs.dropdown.data-api', ':not(.bootstrap-select) > [data-toggle="dropdown"]', bootstrapKeydown)
.on('keydown.bs.dropdown.data-api', ':not(.bootstrap-select) > .dropdown-menu', bootstrapKeydown)
.on('keydown' + EVENT_KEY, '.bootstrap-select [data-toggle="dropdown"], .bootstrap-select [role="listbox"], .bootstrap-select .bs-searchbox input', Selectpicker.prototype.keydown)
.on('focusin.modal', '.bootstrap-select [data-toggle="dropdown"], .bootstrap-select [role="listbox"], .bootstrap-select .bs-searchbox input', function (e) {
e.stopPropagation();
Expand Down

0 comments on commit 1ff4261

Please sign in to comment.