1
0
mirror of synced 2024-11-29 16:16:02 +03:00

Focus is lost when the change event is triggered

This closes https://github.com/select2/select2/issues/3332.
This commit is contained in:
Stretch 2015-06-10 19:18:13 +10:00 committed by Kevin Brown
parent d2346cc331
commit 698fe7b9e1

View File

@ -128,6 +128,8 @@ define([
}; };
Search.prototype.update = function (decorated, data) { Search.prototype.update = function (decorated, data) {
var searchHadFocus = this.$search[0] == document.activeElement;
this.$search.attr('placeholder', ''); this.$search.attr('placeholder', '');
decorated.call(this, data); decorated.call(this, data);
@ -136,6 +138,9 @@ define([
.append(this.$searchContainer); .append(this.$searchContainer);
this.resizeSearch(); this.resizeSearch();
if (searchHadFocus) {
this.$search.focus();
}
}; };
Search.prototype.handleSearch = function () { Search.prototype.handleSearch = function () {