Skip to content
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

iOS issue with no choices available #707

Closed
bryanmills opened this issue Jun 27, 2012 · 2 comments
Closed

iOS issue with no choices available #707

bryanmills opened this issue Jun 27, 2012 · 2 comments

Comments

@bryanmills
Copy link

In iOS there is an issue with the mousedown event which causes the focus to not be set to the input element if there are no choices left to display. You can reproduce this on the demo site (http://harvesthq.github.com/chosen/) by selecting all the choices in the choice list so that nothing is left to choose from.

This issue was very pronounced for me because we were using one of the ajax-chosen plugins which meant that there were no choices at the time of the mousedown event. However, this problem also presents itself in the base chosen plugin if you are out of choices.

The issue is that you stopPropagtion of the event but it appears in iOS you need to go a step further and tell it to prevent the default event behavior. I'm not 100% why this is the case but it does appear to fix the problem.

I would propose the following patch, thoughts?

--- chosen.jquery.js 2012-06-27 15:39:58.274703514 -0400
+++ chosen.jquery.mod.js 2012-06-27 15:41:09.922700056 -0400
@@ -432,6 +432,7 @@
target_closelink = evt != null ? ($(evt.target)).hasClass("search-choice-close") : false;
if (evt && evt.type === "mousedown" && !this.results_showing) {
evt.stopPropagation();

  •      evt.preventDefault();
     }
     if (!this.pending_destroy_click && !target_closelink) {
       if (!this.active_field) {
    
@pohnean
Copy link

pohnean commented Aug 26, 2012

This works for me. I'm also using the ajax-chosen plugin.

@koenpunt
Copy link
Collaborator

I can't reproduce this behavior on the iPad or iOS simulator. If you still have this problem with the latest release feel free to reopen the issue. Also, just recently Chosen is disabled on mobile devices (#1388) and there has been some optimalizations for other touch devices (#1420).
Feel free to reopen this issue if your problem still exists.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants