Merge pull request #2216 from lboynton/fix-search-focus-on-mobile
Fix search focus on mobile
This commit is contained in:
commit
43a598b372
10
select2.js
10
select2.js
@ -1915,6 +1915,7 @@ the specific language governing permissions and limitations under the Apache Lic
|
|||||||
|
|
||||||
this.search.val(this.focusser.val());
|
this.search.val(this.focusser.val());
|
||||||
}
|
}
|
||||||
|
if (this.opts.shouldFocusInput(this)) {
|
||||||
this.search.focus();
|
this.search.focus();
|
||||||
// move the cursor to the end after focussing, otherwise it will be at the beginning and
|
// move the cursor to the end after focussing, otherwise it will be at the beginning and
|
||||||
// new text will appear *before* focusser.val()
|
// new text will appear *before* focusser.val()
|
||||||
@ -1927,6 +1928,7 @@ the specific language governing permissions and limitations under the Apache Lic
|
|||||||
len = this.search.val().length;
|
len = this.search.val().length;
|
||||||
el.setSelectionRange(len, len);
|
el.setSelectionRange(len, len);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// initializes search's value with nextSearchTerm (if defined by user)
|
// initializes search's value with nextSearchTerm (if defined by user)
|
||||||
// ignore nextSearchTerm if the dropdown is opened by the user pressing a letter
|
// ignore nextSearchTerm if the dropdown is opened by the user pressing a letter
|
||||||
@ -2142,7 +2144,11 @@ the specific language governing permissions and limitations under the Apache Lic
|
|||||||
killEvent(e);
|
killEvent(e);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
dropdown.on("mousedown touchstart", this.bind(function() { this.search.focus(); }));
|
dropdown.on("mousedown touchstart", this.bind(function() {
|
||||||
|
if (this.opts.shouldFocusInput(this)) {
|
||||||
|
this.search.focus();
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
|
||||||
selection.on("focus", this.bind(function(e) {
|
selection.on("focus", this.bind(function(e) {
|
||||||
killEvent(e);
|
killEvent(e);
|
||||||
@ -2821,7 +2827,9 @@ the specific language governing permissions and limitations under the Apache Lic
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.updateResults(true);
|
this.updateResults(true);
|
||||||
|
if (this.opts.shouldFocusInput(this)) {
|
||||||
this.search.focus();
|
this.search.focus();
|
||||||
|
}
|
||||||
this.opts.element.trigger($.Event("select2-open"));
|
this.opts.element.trigger($.Event("select2-open"));
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user