[wp-trac] [WordPress Trac] #63897: Generate Password button requires two clicks to update the password field on Add New User screen
WordPress Trac
noreply at wordpress.org
Sun Aug 31 17:46:53 UTC 2025
#63897: Generate Password button requires two clicks to update the password field
on Add New User screen
-------------------------------------------------+-------------------------
Reporter: parthvataliya | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting
| Review
Component: Users | Version: 5.6
Severity: normal | Resolution:
Keywords: has-patch has-test-info dev- | Focuses: javascript
feedback |
-------------------------------------------------+-------------------------
Comment (by taninakond):
Replying to [comment:6 siliconforks]:
> [https://github.com/WordPress/wordpress-develop/pull/9677 PR #9677] is
an alternative proposal which takes the fix which was originally applied
to the "reset password" page and applies it to the "add user" page too.
**Refactor automatic password generation for improved UX and code clarity
on the Add New User and Reset Password pages**
**Remove redundant code:**
The block at lines [https://github.com/WordPress/wordpress-
develop/blob/da59c19dcaae731f64c9f512d35157e356e25931/src/js/_enqueues/admin
/user-profile.js#L533-L542 533–542] that triggered the "Generate Password"
button click on page load is no longer needed. Passwords are already
automatically filled via the bindPass1 function, which calls
generatePassword() on initialization.
**Move network password generation:**
Move the block at lines [https://github.com/WordPress/wordpress-
develop/blob/da59c19dcaae731f64c9f512d35157e356e25931/src/js/_enqueues/admin
/user-profile.js#L264-L268 264–268] to line [https://github.com/WordPress
/wordpress-
develop/blob/da59c19dcaae731f64c9f512d35157e356e25931/src/js/_enqueues/admin
/user-profile.js#L63 63], directly under the generatePassword call. This
ensures that:
- The password field is always initialized with the value set in
$pass1.data('pw'), which comes from PHP and is set at line
[https://github.com/WordPress/wordpress-
develop/blob/da59c19dcaae731f64c9f512d35157e356e25931/src/js/_enqueues/admin
/user-profile.js#L31 31].
- Any network request to fetch a new password happens after the initial
password is set, so there is no delay in showing a password on page load.
- When the user clicks the "Generate Password" button, a new password is
fetched and stored in data-pw, ensuring the latest password is always
available.
**Result:**
On both the Add New User and Reset Password pages, the password field is
immediately filled from the server-provided value. If a new password is
needed, it is fetched without delaying the initial UI, and any user-
initiated password generation fetches a fresh value as expected.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/63897#comment:7>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list