Autofocus is, in theory, completely unsupported in mobile Safari (http://caniuse.com/#feat=autofocus). We're seeing, however, this very strange behaviour where when a touchstart
event is bound to document
(whether the function has any behaviour or not) when a click happens anywhere on the page the first input with autofocus
becomes focused and the onscreen keyboard displays.
This can be reproduced using iOS 8 in the iOS simulator. Here is the minimal html and javascript to reproduce the problem:
<html>
<head>
<script>
document.addEventListener("touchstart", function() {});
</script>
</head>
<body>
<input type="text">
<input type="text" autofocus="autofocus">
</body>
</html>
And here's a jsfiddle: http://jsfiddle.net/qd858nob/
Simply click anywhere outside of the inputs, and the second input will become autofocused. Ideally I'd love to find a global solution that resolves this without having to remove autofocus from all of our input elements.