Opened 8 years ago
Closed 3 years ago
#40302 closed defect (bug) (fixed)
Reset password field is not auto-focused
Reported by: | afercia | Owned by: | audrasjb |
---|---|---|---|
Milestone: | 5.9 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Login and Registration | Keywords: | has-screenshots has-patch commit |
Focuses: | ui | Cc: |
Description
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 (3)
Change History (15)
#1
@
5 years ago
- Keywords has-patch added
My patch above includes 2 changes on 2 different files.
admin/user-profile.js
- Inside thegeneratePassword()
function. After the generated password was set, the new password field will be focused. ThegeneratePassword()
is also use inwp-admin/user-new.php
page, but the added code below doesn't produce any unwanted behaviour.
// Focus the password field. $($pass1Text).focus();
wp-login.php
- I changedlogin_footer( 'user_pass' );
tologin_footer( 'pass1-text' );
. This is to correct the target field of the code below.$input_id
is the string passed inlogin_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/
#3
@
5 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.
#5
@
3 years ago
- Milestone changed from Future Release to 5.9
40302.1.diff
refreshes the previous patch against trunk.
Moving for 5.9 consideration.
This ticket was mentioned in Slack in #core-test by mai21. View the logs.
3 years ago
#7
@
3 years ago
Note: I used .trigger('focus')
in the JS file, but the inline script still has .focus()
.
This ticket was mentioned in Slack in #core by sabernhardt. View the logs.
3 years ago
#10
@
3 years ago
- Keywords commit added; needs-testing removed
This one works fine on my side, marking as ready for commit
.
Patch to focus on new password field on reset password page.