Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

version 3.4.5 does not work correctly on iPad #1949

Closed
boeledi opened this Issue Dec 3, 2013 · 3 comments

Comments

Projects
None yet
2 participants

boeledi commented Dec 3, 2013

Hi,
First of all congratulations for this control.

However, it really does not work on iPad (I tested it on iOS 3.2, and iOS 7).
The problem seems to come from a "focus" issue.

In order to reproduce the problem, let's suppose you have several controls on your page.

Issue 1: Put the focus on any control (other than select2), then touch a select2, everything seems OK. Select any item proposed by select2 and... the keyboard does not hide (=> in fact the cursor is still blinking) => the focus remains on the input control.

Issue 2: Once you already used 1 select2, it is no longer possible to use another one, EXCEPT if you put to focus to another control. Once the focus is put on another control, you can use the select2.

Any solution to this problem?

Many thanks

Owner

kevin-brown commented Dec 3, 2013

This is covered by a few issues, but you already opened #1695 for pretty much the same issue.

A pull request would be great, if you can solve any of the issues. A jsfiddle that reproduces the issue would also help, if you can't make a pull request.

boeledi commented Dec 3, 2013

I finally found out a solution !!

By adding a handle on "touchstart" in method "initContainer" (see below), it now works perfectly (I havent' tested with multiple selection).

Here is the modification to be applied (around line 2030)

         selection.on("mousedown touchstart", "abbr", this.bind(function (e) {  /* DBO: 20131203 added touchstart */
            if (!this.isInterfaceEnabled()) return;
            this.clear();
            killEventImmediately(e);
            this.close();
            this.selection.focus();
        }));

        selection.on("mousedown touchstart", this.bind(function (e) {       /* DBO: 20131203 added touchstart */

            if (!this.container.hasClass("select2-container-active")) {
                this.opts.element.trigger($.Event("select2-focus"));
            }

            if (this.opened()) {
                this.close();
            } else if (this.isInterfaceEnabled()) {
                this.open();
            }

            killEvent(e);
        }));

Could you please validate that there is no side effect?

@boeledi boeledi closed this Dec 3, 2013

boeledi commented Dec 3, 2013

please see the solution here above

@boeledi boeledi reopened this Dec 3, 2013

@ivaynberg ivaynberg closed this in c186dc8 Dec 3, 2013

v-evfila pushed a commit to v-evfila/select2 that referenced this issue Mar 31, 2017

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