Opened 4 years ago
Last modified 18 months ago
#40302 new defect (bug)
Reset password field is not auto-focused
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Future Release | Priority: | normal |
Severity: | normal | Version: | |
Component: | Login and Registration | Keywords: | has-screenshots has-patch needs-testing |
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 (1)
Change History (5)
#1
@
19 months 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/
Patch to focus on new password field on reset password page.