Users: Only set initial focus on the password field on the reset password form#12534
Users: Only set initial focus on the password field on the reset password form#12534i-am-chitti wants to merge 3 commits into
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
|
@i-am-chitti thanks for your PR. While testing, I noticed something I was not aware of. Can you please help me confirm the following:
To my understanding, in See here: wordpress-develop/src/wp-login.php Lines 426 to 435 in 144d701 If it is confirmed, I wonder why the code in |
|
Thanks @afercia for pointing out. I traced it through all three changesets and this JS line has been redundant since it was added. 52193 added it alongside the real fix: correcting wordpress-develop/src/wp-login.php Line 1092 in 144d701 trigger( 'focus' ) just repeats focus the inline script already set. And because $pass1 matches #pass1 / #mailserver_pass on multiple screens, it leaks focus elsewhere.
The follow-ups confirm it: 55974 and 60268 each added a guard ( Is explicit focus required? No — the reset screen keeps its focus via Regressions from removing it? None. Reset password still works; Add New User / install / options-writing have no focus on password field as desired. Hence, I've dropped the block entirely. |
|
@i-am-chitti Thank you for the thorough investigation 👍🏻 |
Removes code in `user-profile.js` that was originally meant to set initial focus to the password field in the reset password screen. The call to setting focus leaked on other pages, for example the Add User page, where setting initial focus to a field in the middle of the form is not desirable. The removed code was redundant anyways, as the reset password screen already comes with an inline script that takes care of initial focus. Developed in #12534 Props iamchitti, afercia. Fixes #65630. git-svn-id: https://develop.svn.wordpress.org/trunk@62764 602fd350-edb4-49c9-b593-d223f7449a82
Removes code in `user-profile.js` that was originally meant to set initial focus to the password field in the reset password screen. The call to setting focus leaked on other pages, for example the Add User page, where setting initial focus to a field in the middle of the form is not desirable. The removed code was redundant anyways, as the reset password screen already comes with an inline script that takes care of initial focus. Developed in WordPress/wordpress-develop#12534 Props iamchitti, afercia. Fixes #65630. Built from https://develop.svn.wordpress.org/trunk@62764 git-svn-id: http://core.svn.wordpress.org/trunk@62048 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Ticket
https://core.trac.wordpress.org/ticket/65630
Description
Setting initial focus on a specific control only makes sense when there is a single, well-defined task for the user. On the Add New User screen, focus is currently placed on the password field in the middle of the form, skipping the Username, Email, and Name fields. This disrupts the native tab order and hurts discoverability for keyboard and screen reader users.
Cause
In
src/js/_enqueues/admin/user-profile.js, the password field is focused whenevergeneratePassword()runs, which happens on every screen where the field carriesdata-reveal="1"— thewp-login.phpreset password form,install.php, anduser-new.php(Add New User).The existing guard is a blocklist that only excludes the mailserver (
#mailserver_pass) and install (#weblog_title) screens, so Add New User slips through and steals focus. The behavior was originally introduced in 52193 and was only ever intended for the reset password field onwp-login.php; the shared selector caused it to leak onto other pages.Testing
wp-admin/user-new.php): focus is no longer forced onto the password field; tab order starts at the top of the form.wp-login.php): password field still receives focus as intended.install.php,options-writing.php(#mailserver_pass),setup-config.php(#pwd, not matched by$pass1).Screenshots
Before
Screen.Recording.2026-07-15.at.12.14.49.PM.mov
After
Screen.Recording.2026-07-15.at.12.14.06.PM.mov