Search focus should also happen in a timeout
For the dropdown search on single select instances, the search focus should happen in a `setTimeout` call. This is because many browsers trigger the element focus on `click`, so our original call to `$search.focus` will essentially be ignored. By also focusing it in a timeout, this will delay the call to `focus` so the browser will no longer take it back. We do not have this issue for multiple select instances, as they trigger the `open` event on `click`, instead of using `mousedown`. This fixes https://github.com/select2/select2/issues/2900.
This commit is contained in:
parent
e76460a392
commit
68286e3cff
4
dist/js/select2.amd.full.js
vendored
4
dist/js/select2.amd.full.js
vendored
@ -2890,6 +2890,10 @@ define('select2/dropdown/search',[
|
||||
self.$search.attr('tabindex', 0);
|
||||
|
||||
self.$search.focus();
|
||||
|
||||
window.setTimeout(function () {
|
||||
self.$search.focus();
|
||||
}, 0);
|
||||
});
|
||||
|
||||
container.on('close', function () {
|
||||
|
4
dist/js/select2.amd.js
vendored
4
dist/js/select2.amd.js
vendored
@ -2890,6 +2890,10 @@ define('select2/dropdown/search',[
|
||||
self.$search.attr('tabindex', 0);
|
||||
|
||||
self.$search.focus();
|
||||
|
||||
window.setTimeout(function () {
|
||||
self.$search.focus();
|
||||
}, 0);
|
||||
});
|
||||
|
||||
container.on('close', function () {
|
||||
|
4
dist/js/select2.full.js
vendored
4
dist/js/select2.full.js
vendored
@ -12425,6 +12425,10 @@ define('select2/dropdown/search',[
|
||||
self.$search.attr('tabindex', 0);
|
||||
|
||||
self.$search.focus();
|
||||
|
||||
window.setTimeout(function () {
|
||||
self.$search.focus();
|
||||
}, 0);
|
||||
});
|
||||
|
||||
container.on('close', function () {
|
||||
|
2
dist/js/select2.full.min.js
vendored
2
dist/js/select2.full.min.js
vendored
File diff suppressed because one or more lines are too long
4
dist/js/select2.js
vendored
4
dist/js/select2.js
vendored
@ -3318,6 +3318,10 @@ define('select2/dropdown/search',[
|
||||
self.$search.attr('tabindex', 0);
|
||||
|
||||
self.$search.focus();
|
||||
|
||||
window.setTimeout(function () {
|
||||
self.$search.focus();
|
||||
}, 0);
|
||||
});
|
||||
|
||||
container.on('close', function () {
|
||||
|
2
dist/js/select2.min.js
vendored
2
dist/js/select2.min.js
vendored
File diff suppressed because one or more lines are too long
4
src/js/select2/dropdown/search.js
vendored
4
src/js/select2/dropdown/search.js
vendored
@ -40,6 +40,10 @@ define([
|
||||
self.$search.attr('tabindex', 0);
|
||||
|
||||
self.$search.focus();
|
||||
|
||||
window.setTimeout(function () {
|
||||
self.$search.focus();
|
||||
}, 0);
|
||||
});
|
||||
|
||||
container.on('close', function () {
|
||||
|
Loading…
x
Reference in New Issue
Block a user