minimumResultsForSearch: -1 prevents dropdown from opening on iPhone

In my web application, I have a select2 control that won’t open on iPhones. After spending an hour or so on BrowserStack, I can report it works fine on iPad, Android and all desktop browsers, but not on iPhone. On iPhone the native SELECT is upgraded to a select2, but tapping on the control leads to a brief flicker, but the menu does not open.

The problem goes away when I use “minimumResultsForSearch: 0”. Any other value causes it to fail.

I wanted to report this as a github issue but my attempts to reproduce this in jsfiddle so far has failed. It’s 100% reproducible in my app, but I don’t have time right now to continue paring down the page to something I can easily publish on the public internet. This post is for the benefit of developers and fellow users.

Tested with select2 version 4.0.7, jquery 1.12.4. First discovered the problem on an iPhone 5C with iOS 10.3.3.

It appears you’re using a very old version of jQuery. The latest jQuery version is 3.4.1. Have you tried upgrading jQuery to see if that solves the problem on mobile Safari?

Since you can’t reproduce this on, that would seem to indicate that the issue is somewhere in your code (assuming all other things are equal—e.g., that you’re using the same versions of Select2 and jQuery in your fiddle as you are in your actual web app). If iPhone users are a critical segment of your customer base, you might need to take the time to figure out how to reproduce this issue on; doing so may lead you to the code that is causing this issue.

And, for what it’s worth, the Select2 configuration documentation does not indicate that -1 is an allowable value for the “minimumResultsForSearch” property. 0 is the default value, and by the nature of the property it would seem that only non-negative integer values make sense for it.