Tapping below Bootstrap inputs can focus them in Mobile Safari #15968

Closed
asafbrukarz opened this Issue Mar 2, 2015 · 19 comments

5 participants

@asafbrukarz

This one has had me puzzled for a while and I've been trying to find a more specific cause, but I haven't managed to narrow it down further than Bootstrap.

The fiddle here is set up as follows:

When clicking in the area marked in red:
ios-simulator-screen-shot-2-mar-2015-11 25

The input is focused:
ios simulator screen shot 2 mar 2015 11 33 45 am

The issue here is two-fold:
1. Touching anywhere on the screen trigger the input to focus - this even occurs on a scroll event
2. The keyboard does not pop-up. Even if a user wanted to enter text into the input, they need to click it again to trigger the keyboard.

I have been able to confirm the following:
1. Removing EITHER bootstrap.min.css or bootstrap.min.js fixes the issue.
2. Removing class: form-control from the input style fixes the issue.
3. Mobile Safari does not attempt to autofocus form elements on its own.

Greatly appreciate your help in tracking down this issue. I'm not sure if it's a browser bug (caused by adding :focus styles to an element with the autofocus attribute set), or a javascript event.

@twbs-lmvtfy
Bootstrap member

Hi @asafbrukarz!

You appear to have posted a live example (http://fiddle.jshell.net/9ryem7u4/show/light/), which is always a good first step. However, according to Bootlint, your example has some Bootstrap usage errors, which might potentially be causing your issue:

  • line 39, column 5: E003: Found one or more .rows that were not children of a grid column or descendants of a .container or .container-fluid

You'll need to fix these errors and post a revised example before we can proceed further.
Thanks!

(Please note that this is a fully automated comment.)

@cvrebert cvrebert added the css label Mar 2, 2015
@asafbrukarz

Update the fiddle to remove superfluous rows and grids.

@cvrebert
Bootstrap member
cvrebert commented Mar 2, 2015

Possible duplicate of #14532.

@cvrebert
Bootstrap member
cvrebert commented Mar 2, 2015

None of our JS should be getting activated in this case, so the bug is very unlikely to be JS-related.

@asafbrukarz

@cvrebert I wouldn't have thought that it was JS related either, but removing the JS file certainly makes a difference.

@cvrebert
Bootstrap member
cvrebert commented Mar 2, 2015

Right, but none of our JavaScript acts unbidden on forms or plain text form-controls... Maybe the mere act of adding a document event listener has some weird side-effect on Safari? IDK, just spitballing here.

@cvrebert cvrebert added the confirmed label Mar 2, 2015
@hnrch02
Bootstrap member
hnrch02 commented Mar 2, 2015

Uhm, according to http://caniuse.com/#feat=autofocus autofocus isn't even implemented in iOS Safari.

@cvrebert
Bootstrap member
cvrebert commented Mar 2, 2015

Fork without the autofocus attribute: http://jsfiddle.net/gzxtb86c/3/

@cvrebert
Bootstrap member
cvrebert commented Mar 2, 2015

Yup, still happens without autofocus.

@cvrebert cvrebert changed the title from Bootstrap inputs with autofocus act strangely in Mobile Safari to Tapping below Bootstrap inputs can focus them in Mobile Safari Mar 2, 2015
@cvrebert
Bootstrap member
cvrebert commented Mar 2, 2015

Also, I can't repro the "keyboard doesn't pop up" part with either fiddle. Using iOS 8.1 on an actual iPhone 5S.

@asafbrukarz

You're correct. It's only on the simulator that the keyboard doesn't pop up.

Also, a touch start event will trigger this behaviour, so it's not limited to tapping.

@asafbrukarz asafbrukarz closed this Mar 2, 2015
@asafbrukarz asafbrukarz reopened this Mar 2, 2015
@asafbrukarz

Sorry, I accidentally closed this issue.

The other point to note is that in your fork the focus style is not applied to the input, where in the original, the blue outline has been applied - even though Mobile Safari should not support autofocus at all.

@asafbrukarz

Just confirming that this is still an issue in 3.3.4

@mdo
Bootstrap member
mdo commented Apr 25, 2015

Is this a browser bug then that needs reporting?

@asafbrukarz
@mdo
Bootstrap member
mdo commented May 14, 2015

Anyone willing to test this out? If not, I'm probably going to punt on it until after v4.

@cvrebert
Bootstrap member

@mdo Already confirmed it earlier.
Filed WebKit bug: https://bugs.webkit.org/show_bug.cgi?id=146244

@cvrebert
Bootstrap member
@cvrebert cvrebert added this to the v3.3.6 milestone Jun 23, 2015
@cvrebert cvrebert added a commit that referenced this issue Jun 23, 2015
@cvrebert cvrebert Add Wall of Browser Bugs entry for #15968
Closes #15968.
[skip sauce]
52140f3
@cvrebert cvrebert closed this in #16691 Jun 23, 2015
@cvrebert
Bootstrap member
cvrebert commented Nov 3, 2015
@cvrebert cvrebert added a commit that referenced this issue Nov 3, 2015
@cvrebert cvrebert Port 33103c0 to v3
http://wkbug.com/146244 has been fixed in WebKit Nightly

See http://trac.webkit.org/changeset/191954
Refs #15968

[ci skip]
857d9d6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment