Skip to content

Commit b94e8dc

Browse files
committed
Do not autofocus text fields on page load on mobile devices. This is currently broken in many mobile browsers:
- iOS Safari opens the keyboard and auto-scrolls on the first tap anywhere on the screen triggering the click at an unexpected place. That makes it impossible to follow links or press buttons. - Chrome on iOS opens the keyboard on load and may scroll the focused field off screen. - The Android 4.4 browser only highlights the field, the user has to tap it to open the keyboard and type. Merges [30842] to the 4.1 branch. See #30703. git-svn-id: https://develop.svn.wordpress.org/branches/4.1@30908 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 0f814d6 commit b94e8dc

4 files changed

Lines changed: 10 additions & 1 deletion

File tree

src/wp-admin/edit-form-advanced.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,7 @@
647647
wp_comment_reply();
648648
?>
649649

650-
<?php if ( post_type_supports( $post_type, 'title' ) && '' === $post->post_title ) : ?>
650+
<?php if ( ! wp_is_mobile() && post_type_supports( $post_type, 'title' ) && '' === $post->post_title ) : ?>
651651
<script type="text/javascript">
652652
try{document.post.title.focus();}catch(e){}
653653
</script>

src/wp-admin/edit-form-comment.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,8 @@
155155
</div>
156156
</form>
157157

158+
<?php if ( ! wp_is_mobile() ) : ?>
158159
<script type="text/javascript">
159160
try{document.post.name.focus();}catch(e){}
160161
</script>
162+
<?php endif;

src/wp-admin/edit-tag-form.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,9 @@
200200
?>
201201
</form>
202202
</div>
203+
204+
<?php if ( ! wp_is_mobile() ) : ?>
203205
<script type="text/javascript">
204206
try{document.forms.edittag.name.focus();}catch(e){}
205207
</script>
208+
<?php endif;

src/wp-admin/edit-tags.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -583,10 +583,14 @@
583583

584584
</div><!-- /col-container -->
585585
</div><!-- /wrap -->
586+
587+
<?php if ( ! wp_is_mobile() ) : ?>
586588
<script type="text/javascript">
587589
try{document.forms.addtag['tag-name'].focus();}catch(e){}
588590
</script>
589591
<?php
592+
endif;
593+
590594
$wp_list_table->inline_edit();
591595

592596
include( ABSPATH . 'wp-admin/admin-footer.php' );

0 commit comments

Comments
 (0)