Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes IE11 issue with select losing focus having selected an item. #4860

Closed
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/js/select2/selection/base.js
Expand Up @@ -82,6 +82,9 @@ define([
self.$selection.removeAttr('aria-owns');

self.$selection.focus();
window.setTimeout(function () {
self.$selection.focus();
}, 0);

self._detachCloseHandler(container);
});
Expand Down
2 changes: 1 addition & 1 deletion src/js/select2/selection/search.js
Expand Up @@ -175,7 +175,7 @@ define([

this.resizeSearch();
if (searchHadFocus) {
this.$search.focus();
this.$element.focus();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this have side effects on other types of inputs? I did another PR which only modifies the behaviour for tag input as a precaution. https://github.com/select2/select2/pull/4958/files

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$element.focus() invokes the focus function of the select2 plugin, not the "tag". This function should handle all cases so I don't think it has any side effects. We are using select elements in our solutions and the bug needs fixing for that too.

Did I understand you correctly?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}
};

Expand Down