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.
See #30703.
Built from https://develop.svn.wordpress.org/trunk@30842


git-svn-id: http://core.svn.wordpress.org/trunk@30832 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Andrew Ozz 2014-12-13 22:08:23 +00:00
parent da7d68af53
commit 7cc113ab66
4 changed files with 10 additions and 1 deletions

View File

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

View File

@ -155,6 +155,8 @@ do_meta_boxes(null, 'normal', $comment);
</div>
</form>
<?php if ( ! wp_is_mobile() ) : ?>
<script type="text/javascript">
try{document.post.name.focus();}catch(e){}
</script>
<?php endif;

View File

@ -200,6 +200,9 @@ submit_button( __('Update') );
?>
</form>
</div>
<?php if ( ! wp_is_mobile() ) : ?>
<script type="text/javascript">
try{document.forms.edittag.name.focus();}catch(e){}
</script>
<?php endif;

View File

@ -583,10 +583,14 @@ do_action( "{$taxonomy}_add_form", $taxonomy );
</div><!-- /col-container -->
</div><!-- /wrap -->
<?php if ( ! wp_is_mobile() ) : ?>
<script type="text/javascript">
try{document.forms.addtag['tag-name'].focus();}catch(e){}
</script>
<?php
endif;
$wp_list_table->inline_edit();
include( ABSPATH . 'wp-admin/admin-footer.php' );