Skip to content

Commit 877bf3d

Browse files
committed
Users: Fix Generate Password button requiring two clicks to update the password field on the Add New User screen.
The password was previously set before the AJAX response returned, resulting in the first click not updating the password field. This change moves the `generatePassword()` call inside the AJAX callback to ensure the password is always updated immediately. Props taninahmed. Fixes #63897.
1 parent 2fe30e7 commit 877bf3d

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/js/_enqueues/admin/user-profile.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -255,16 +255,15 @@
255255
$pass1.attr( 'disabled', false );
256256
$pass2.attr( 'disabled', false );
257257

258-
// Set the password to the generated value.
259-
generatePassword();
260-
261258
// Show generated password in plaintext by default.
262259
resetToggle ( false );
263260

264261
// Generate the next password and cache.
265262
wp.ajax.post( 'generate-password' )
266263
.done( function( data ) {
267264
$pass1.data( 'pw', data );
265+
// Set the password to the generated value.
266+
generatePassword();
268267
} );
269268
} );
270269

0 commit comments

Comments
 (0)