Skip to content

Commit 1ff4261

Browse files
committed
remove Bootstrap keydown event listeners and re-add for non bootstrap-select selectors. $.off requires the selector matches exactly so the previous method didn't work. (#2308)
1 parent a5b0752 commit 1ff4261

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

js/bootstrap-select.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3125,8 +3125,13 @@
31253125
return this;
31263126
};
31273127

3128+
// get Bootstrap's keydown event handler for either Bootstrap 4 or Bootstrap 3
3129+
var bootstrapKeydown = $.fn.dropdown.Constructor._dataApiKeydownHandler || $.fn.dropdown.Constructor.prototype.keydown;
3130+
31283131
$(document)
3129-
.off('keydown.bs.dropdown.data-api', '.bootstrap-select [data-toggle="dropdown"], .bootstrap-select .dropdown-menu')
3132+
.off('keydown.bs.dropdown.data-api')
3133+
.on('keydown.bs.dropdown.data-api', ':not(.bootstrap-select) > [data-toggle="dropdown"]', bootstrapKeydown)
3134+
.on('keydown.bs.dropdown.data-api', ':not(.bootstrap-select) > .dropdown-menu', bootstrapKeydown)
31303135
.on('keydown' + EVENT_KEY, '.bootstrap-select [data-toggle="dropdown"], .bootstrap-select [role="listbox"], .bootstrap-select .bs-searchbox input', Selectpicker.prototype.keydown)
31313136
.on('focusin.modal', '.bootstrap-select [data-toggle="dropdown"], .bootstrap-select [role="listbox"], .bootstrap-select .bs-searchbox input', function (e) {
31323137
e.stopPropagation();

0 commit comments

Comments
 (0)