Skip to content

Commit 6b689fc

Browse files
committed
Merge pull request select2#2302 from ivaynberg/issue_1541
Only disable keyboard focusing for touch devices
2 parents 514988e + 2e79f5e commit 6b689fc

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

select2.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3387,6 +3387,15 @@ the specific language governing permissions and limitations under the Apache Lic
33873387
searchInputPlaceholder: '',
33883388
createSearchChoicePosition: 'top',
33893389
shouldFocusInput: function (instance) {
3390+
// Attempt to detect touch devices
3391+
var supportsTouchEvents = (('ontouchstart' in window) ||
3392+
(navigator.msMaxTouchPoints > 0));
3393+
3394+
// Only devices which support touch events should be special cased
3395+
if (!supportsTouchEvents) {
3396+
return true;
3397+
}
3398+
33903399
// Never focus the input if search is disabled
33913400
if (instance.opts.minimumResultsForSearch < 0) {
33923401
return false;

0 commit comments

Comments
 (0)