Login and Registration: Remove `aria-expanded` from "Generate Password" button.

During password resets, the 'Generate Password" button has a `aria-expanded="true"` attribute, but the button itself does not expand or collapse anything.  This change adds a `skip-aria-expanded` class to the button which is referenced in JavaScript to skip updating the `aria-expanded` attribute on the button itself when clicked.  

This change also resets the `aria-expanded` attribute to `false` for the parent form after it's submitted.

Props alexstine, johnjamesjacoby, sabernhardt.
Fixes #54538.
Built from https://develop.svn.wordpress.org/trunk@52450


git-svn-id: http://core.svn.wordpress.org/trunk@52042 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
davidbaumwald 2022-01-05 17:37:03 +00:00
parent 9f9440a039
commit 55aaefe766
4 changed files with 6 additions and 4 deletions

View File

@ -216,7 +216,7 @@
updateLock = true; updateLock = true;
// Make sure the password fields are shown. // Make sure the password fields are shown.
$generateButton.attr( 'aria-expanded', 'true' ); $generateButton.not( '.skip-aria-expanded' ).attr( 'aria-expanded', 'true' );
$passwordWrapper $passwordWrapper
.show() .show()
.addClass( 'is-open' ); .addClass( 'is-open' );
@ -257,6 +257,8 @@
// Stop an empty password from being submitted as a change. // Stop an empty password from being submitted as a change.
$submitButtons.prop( 'disabled', false ); $submitButtons.prop( 'disabled', false );
$generateButton.attr( 'aria-expanded', 'false' );
} ); } );
$pass1Row.closest( 'form' ).on( 'submit', function () { $pass1Row.closest( 'form' ).on( 'submit', function () {

File diff suppressed because one or more lines are too long

View File

@ -16,7 +16,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '6.0-alpha-52449'; $wp_version = '6.0-alpha-52450';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.

View File

@ -979,7 +979,7 @@ switch ( $action ) {
?> ?>
<input type="hidden" name="rp_key" value="<?php echo esc_attr( $rp_key ); ?>" /> <input type="hidden" name="rp_key" value="<?php echo esc_attr( $rp_key ); ?>" />
<p class="submit reset-pass-submit"> <p class="submit reset-pass-submit">
<button type="button" class="button wp-generate-pw hide-if-no-js" aria-expanded="true"><?php _e( 'Generate Password' ); ?></button> <button type="button" class="button wp-generate-pw hide-if-no-js skip-aria-expanded"><?php _e( 'Generate Password' ); ?></button>
<input type="submit" name="wp-submit" id="wp-submit" class="button button-primary button-large" value="<?php esc_attr_e( 'Save Password' ); ?>" /> <input type="submit" name="wp-submit" id="wp-submit" class="button button-primary button-large" value="<?php esc_attr_e( 'Save Password' ); ?>" />
</p> </p>
</form> </form>