diff --git a/select2.js b/select2.js index ea175cf7..4331225d 100644 --- a/select2.js +++ b/select2.js @@ -3384,6 +3384,15 @@ the specific language governing permissions and limitations under the Apache Lic searchInputPlaceholder: '', createSearchChoicePosition: 'top', shouldFocusInput: function (instance) { + // Attempt to detect touch devices + var supportsTouchEvents = (('ontouchstart' in window) || + (navigator.msMaxTouchPoints > 0)); + + // Only devices which support touch events should be special cased + if (!supportsTouchEvents) { + return true; + } + // Never focus the input if search is disabled if (instance.opts.minimumResultsForSearch < 0) { return false;