Skip to content

Commit 698fe7b

Browse files
stretch4x4kevin-brown
authored andcommitted
Focus is lost when the change event is triggered
This closes select2#3332.
1 parent d2346cc commit 698fe7b

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

src/js/select2/selection/search.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,8 @@ define([
128128
};
129129

130130
Search.prototype.update = function (decorated, data) {
131+
var searchHadFocus = this.$search[0] == document.activeElement;
132+
131133
this.$search.attr('placeholder', '');
132134

133135
decorated.call(this, data);
@@ -136,6 +138,9 @@ define([
136138
.append(this.$searchContainer);
137139

138140
this.resizeSearch();
141+
if (searchHadFocus) {
142+
this.$search.focus();
143+
}
139144
};
140145

141146
Search.prototype.handleSearch = function () {

0 commit comments

Comments
 (0)