Make WordPress Core

Opened 4 years ago

Last modified 2 years ago

#40302 new defect (bug)

Reset password field is not auto-focused

Reported by: afercia Owned by:
Milestone: Future Release Priority: normal
Severity: normal Version:
Component: Login and Registration Keywords: has-screenshots has-patch needs-testing
Focuses: ui Cc:


See also #40301 and #30023.

Although auto-focusing form fields can be arguable in some cases, I'd say it makes sense when there's a very specific task to accomplish and when there's no relevant content before the auto-focused field. In that case, the relevant content would be "skipped" for some users, see #40301.

Ideally, there should be some consistency. I see no reasons why, for example, the lost password field gets auto-focused and the reset password field doesn't.

As far as I see, this has always worked this way, even before the introduction of auto-generated password, because in the reset password screen there's no field with an user_pass ID.

With JS on, the field to focus has a pass1-text ID but the only relevant code in the page tries to target an element with the ID user_pass:


With JS off, well... I guess it's a bit pointless but the relevant field has a pass1 ID.


Attachments (1)

40302.diff (704 bytes) - added by donmhico 2 years ago.
Patch to focus on new password field on reset password page.

Download all attachments as: .zip

Change History (5)

2 years ago

Patch to focus on new password field on reset password page.

#1 @donmhico
2 years ago

  • Keywords has-patch added

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.
  1. 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();


#2 @SergeyBiryukov
2 years ago

  • Milestone changed from Awaiting Review to 5.3

#3 @davidbaumwald
2 years ago

  • Keywords needs-testing added

The patest patch for this ticket still needs testing. With Beta 1 of version 5.3 only a few days away, this is being moved to Future Release. If this ticket can be resolved in time for 5.3, feel free to re-milestone.

#4 @davidbaumwald
2 years ago

  • Milestone changed from 5.3 to Future Release
Note: See TracTickets for help on using tickets.