Skip to content

Commit d559b6f

Browse files
committed
Fix select2 input focus & select2 multiple input remove
1 parent d388329 commit d559b6f

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/resources/views/crud/form_content.blade.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,19 @@ function triggerFocusOnFirstInputField(firstField) {
8080
* @param {jQuery} firstField
8181
*/
8282
function handleFocusOnSelect2Field(firstField){
83-
$('.select2-search__field').remove();
8483
firstField.select2('focus');
8584
}
8685
86+
/*
87+
* Hacky fix for a bug in select2 with jQuery 3.6.0's new nested-focus "protection"
88+
* see: https://github.com/select2/select2/issues/5993
89+
* see: https://github.com/jquery/jquery/issues/4382
90+
*
91+
*/
92+
$(document).on('select2:open', () => {
93+
setTimeout(() => document.querySelector('.select2-container--open .select2-search__field').focus(), 200);
94+
});
95+
8796
jQuery('document').ready(function($){
8897
8998
// trigger the javascript for all fields that have their js defined in a separate method

0 commit comments

Comments
 (0)