[wp-trac] [WordPress Trac] #40302: Reset password field is not auto-focused

WordPress Trac noreply at wordpress.org
Tue Aug 6 12:33:45 UTC 2019


#40302: Reset password field is not auto-focused
---------------------------------------+------------------------------
 Reporter:  afercia                    |       Owner:  (none)
     Type:  defect (bug)               |      Status:  new
 Priority:  normal                     |   Milestone:  Awaiting Review
Component:  Login and Registration     |     Version:
 Severity:  normal                     |  Resolution:
 Keywords:  has-screenshots has-patch  |     Focuses:  ui
---------------------------------------+------------------------------
Changes (by donmhico):

 * keywords:  has-screenshots => has-screenshots has-patch


Comment:

 My patch above includes 2 changes on 2 different files.

 1. `admin/user-profile.js` - Inside the `generatePassword()` function.
 After the generated password was set, the new password field will be
 focused. The `generatePassword()` is also use in `wp-admin/user-new.php`
 page, but the added code below doesn't produce any unwanted behaviour.

 {{{
 // Focus the password field.
 $($pass1Text).focus();
 }}}

 2. `wp-login.php` - I changed `login_footer( 'user_pass' );` to
 `login_footer( 'pass1-text' );`. This is to correct the target field of
 the code below. `$input_id` is the string passed in `login_footer()`.

 {{{
 <script type="text/javascript">
     try{document.getElementById('<?php echo $input_id;
 ?>').focus();}catch(e){}
     if(typeof wpOnload=='function')wpOnload();
 </script>
 }}}

 Reference:
 https://developer.wordpress.org/reference/functions/login_footer/

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/40302#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list