Check if search input should be focussed when opening
This commit is contained in:
parent
cbd2a70dc3
commit
ad21d01693
24
select2.js
24
select2.js
@ -1915,17 +1915,19 @@ the specific language governing permissions and limitations under the Apache Lic
|
|||||||
|
|
||||||
this.search.val(this.focusser.val());
|
this.search.val(this.focusser.val());
|
||||||
}
|
}
|
||||||
this.search.focus();
|
if (this.opts.shouldFocusInput(this)) {
|
||||||
// move the cursor to the end after focussing, otherwise it will be at the beginning and
|
this.search.focus();
|
||||||
// new text will appear *before* focusser.val()
|
// move the cursor to the end after focussing, otherwise it will be at the beginning and
|
||||||
el = this.search.get(0);
|
// new text will appear *before* focusser.val()
|
||||||
if (el.createTextRange) {
|
el = this.search.get(0);
|
||||||
range = el.createTextRange();
|
if (el.createTextRange) {
|
||||||
range.collapse(false);
|
range = el.createTextRange();
|
||||||
range.select();
|
range.collapse(false);
|
||||||
} else if (el.setSelectionRange) {
|
range.select();
|
||||||
len = this.search.val().length;
|
} else if (el.setSelectionRange) {
|
||||||
el.setSelectionRange(len, len);
|
len = this.search.val().length;
|
||||||
|
el.setSelectionRange(len, len);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// initializes search's value with nextSearchTerm (if defined by user)
|
// initializes search's value with nextSearchTerm (if defined by user)
|
||||||
|
Loading…
Reference in New Issue
Block a user