-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Disable Chosen on iOS devices (iPad, iPod, iPhone) #1388
Conversation
Seems like a good idea to me. |
Maybe we should do the same for Android. https://github.com/harvesthq/chosen/issues?direction=desc&labels=Android&page=1&sort=created&state=open |
@@ -204,6 +204,8 @@ class AbstractChosen | |||
@browser_is_supported: -> | |||
if window.navigator.appName == "Microsoft Internet Explorer" | |||
return null isnt document.documentMode >= 8 | |||
if /iP(ad|od|hone)/.test(window.navigator.userAgent) | |||
return false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two lines up, we're returning null
instead of false
. Should probably be consistent. (Though probably consistent with false
, not null
.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I'd rather we change two lines up to be false
. We're returning true
by default and I think it's better to assume that a method name like browser_is_supported
will return a boolean (or a JavaScript approximation of a boolean).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh - I see @koenpunt's reply below and he's right. We're not returning null
, we're returning the value of the comparison. Carry on.
Would close #409 as well. |
We're not returning null, we're comparing to null ;) |
Or is |
@koenpunt I really have no idea there. That line should probably be rewritten altogether :) |
On the iPhone, I don't think there should be any question that Chosen should be disabled. The keyboard covers up the list and searching is awkward. On iPad, it's less cut and dry. When you zoom in on Chosen, I think it's probably better than the default select control. When it's at 1:1, it's probably a slight edge to the native select (but only because of size). I'm not sure we should make a choice like this for a developer when it's totally functional on iPad. People can opt out when they apply Chosen, no? I'm not sure what to say about Android. I assume the small form factor problem the iPhone presents is also a problem on Android phones, but is there an easy way to separate phones vs. tablets? I guess there it would make sense to block all devices. Confusing. |
I've updated the tests that only iPod and iPhone are not supported and neither are Android devices if the useragent string contains mobile. |
Disable Chosen on iPhone / iPod and Android mobile devices by default
- CSS Updates #1368, #1371 - Prevent text selection on Chosen #1374 - single_backstroke_delete defaults to true #1375 - No longer expose classes to window context #1389 - Single select value fix #1392 - Remove javascript:void and attr references #1385, #1377 - Disable Chosen on iPhone / iPod and Android mobile devices by default #1388 - Add Destroy Method #1396 - Option to Hide Selected & Disabled Options #1404 - Always clear result highlight #1407 - Replace characters only once #1411 - Document all the things. #1366, #1376, #1383 - Add Gemfile for compass dependency #1373 - Update copyright and license link #1397 - Add @koenpunt as a maintainer #1399 - Add anchors to documentation headers #1395 - Updated stackoverflow instructions #1403
Hmmm... it's not an even trade, as on the iPhone, there's no typeahead for the select. If you're using chosen for a list of 3500 places (like me), there's going to be a lot of swiping. |
It's easy enough to undo this change in your own project if you feel Chosen is better (just remove the test). This change is about making Chosen's default settings the best they can be. |
@pfiller then maybe it should be an option (defaulting to disable on mobile) instead of forcing to edit the source and recompile it ? |
As well as AbstractChosen.default_multiple_text = "Select Some Options"; AbstractChosen.default_single_text = "Select an Option"; AbstractChosen.default_no_result_text = "No results match"; which would be nice to be able to pass in as an option (the tool I'm using can't write the data-placeholder) for multi-language use. But of course hacking the plugin is an option, just normally developers discourage that :-) |
I've disabled the test for mobile in my setup. For me, that's better, thanks |
The Chosen UI doesn't behave correctly on iPad devices. It just shows the list of options below the Chosen control and doesn't allow the user to select one. I tested this on iPad using both Chrome and Safari and got the same behavior on both. I recommend adding the iPad to the detection code for unsupported browsers. |
"It's easy enough to undo this change in your own project if you feel Chosen is better (just remove the test). This change is about making Chosen's default settings the best they can be." by pfiller Could you please add the browser check as a constuctor option. In my case chosen works like a charm on the static disabled devices. |
You can alter the display of the select's on mobile by just using CSS. |
Has anyone been able to use Chosen on mobile devices? |
I tried to activate chosen(only basic single dropdown) on iPad/iPhone/Android and everything seems to be okay. |
I agree an option would be nice. I've hacked the code to make the test fail, thereby getting Chosen to work on mobile, but that's obviously not ideal since it'll be overwritten if/when I update Chosen to any newer version. At the very least, if it's the search field that is believed to present visual problems on mobile, maybe have the test only apply when search is enabled. But a full option would still be best. |
There is any way to turn on support for iOS and Android devices without hacking chosen lib? |
@rafalenden you can override the function. Provided you override it before you initialise chosen it seems to work ok. AbstractChosen.browser_is_supported = function() { return true; } // or replace with your own tests to return false/true |
@Ruxton the |
I'm using jQuery version. |
Rather than redefining Then devs who want to have a consistent UI experience (and have multiple selected elements shown nicely on-screen) without the weirdness of the on-screen keyboard can have it. Of course, this only works if search is disabled, so a valid argument could be made for an Anyway... my 2c. |
I've created fork that works on mobile devices. |
Seems to work fine on Android 4.4 ... will test in iPad etc. so i agree with above people we should get an easy to set option to override this behavour. |
Hi Marc..is this working for you on all mobile and touch devices ? If yes could you pls share your... code here.. |
manmohan-bisht: i just followed what others said to do; on line 504 I did this to the function there
I've tested on iPad 2 (fully updated, not sure what version that means), and Android 4.2+ and it seems to work just fine. Can scroll a bit "funny" but works well enough. |
I agree with rockethouse (may 7 2014) |
Hi, any plans to make Chosen stable on iOS and Android ? |
If support for Chosen is eventually added I think it would be a good idea to simply use a full screen view (filter + list) for the phone and small tablet use cases. This mimics the native combo boxes and offers the best usability for users, especially a big chunk of the screen is taken up by a keyboard. |
@koenpeters I like that thought! But probably required a LOT of CSS updates. |
@mlettini maybe you can do a suggestion on what @koenpeters idea could look like? |
@koenpunt @koenpeters That is a neat idea, and it might be doable, but it probably requires JS changes too. Because if we're talking CSS-only then you'd need to move the Chosen select out of it's position, which would require If I had the time, I might try a prototype, but alas, I don't right now. |
Issues with |
@koenpeters @koenpunt @mlettini Any additional discussion about enabling Chosen on mobile should probably be a new issue. You can link back to this thread, but this thread is "closed" (via merge), so it's more likely to get lost when people are looking for open feature issues. @koenpeters Do you mind opening a new issue summarizing from your comment down? |
As a solution (until actual support is implemented?) for #27, #382, #1088 and #1233 I've flagged iOS browsers as unsupported.