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.

git-svn-id: https://develop.svn.wordpress.org/trunk@52450 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
David Baumwald
2022-01-05 17:35:44 +00:00
parent 6ca73cb648
commit 580e57a6e0
2 changed files with 4 additions and 2 deletions

View File

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

View File

@@ -979,7 +979,7 @@ switch ( $action ) {
?>
<input type="hidden" name="rp_key" value="<?php echo esc_attr( $rp_key ); ?>" />
<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' ); ?>" />
</p>
</form>