Skip to content

Commit

Permalink
Application Passwords: Allow enter key to submit profile form.
Browse files Browse the repository at this point in the history
Fix the enter key in profile form fields moving focus to the application password input instead of submitting the profile update for. Replace the submit button type used for application passwords with `button type="button"` and ensure that the enter key's native behavior isn't overwritten.

props audrasjb, alexstine, promz, sabernhardt.
Fixes #52849.
Built from https://develop.svn.wordpress.org/trunk@51086


git-svn-id: http://core.svn.wordpress.org/trunk@50695 1a063a9b-81f0-0310-95a4-ce76da25c4cd
  • Loading branch information
joedolson committed Jun 7, 2021
1 parent 34cfd7e commit e53ace6
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 16 deletions.
24 changes: 11 additions & 13 deletions wp-admin/includes/class-wp-application-passwords-list-table.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,15 +110,13 @@ public function column_last_ip( $item ) {
* @param array $item The current application password item.
*/
public function column_revoke( $item ) {
submit_button(
__( 'Revoke' ),
'delete',
'revoke-application-password-' . $item['uuid'],
false,
array(
/* translators: %s: the application password's given name. */
'aria-label' => sprintf( __( 'Revoke "%s"' ), $item['name'] ),
)
$name = 'revoke-application-password-' . $item['uuid'];
printf(
'<button type="button" name="%1$s" id="%1$s" class="button delete" aria-label="%2$s">%3$s</button>',
esc_attr( $name ),
/* translators: %s: the application password's given name. */
esc_attr( sprintf( __( 'Revoke "%s"' ), $item['name'] ) ),
__( 'Revoke' )
);
}

Expand Down Expand Up @@ -156,7 +154,7 @@ protected function display_tablenav( $which ) {
<div class="tablenav <?php echo esc_attr( $which ); ?>">
<?php if ( 'bottom' === $which ) : ?>
<div class="alignright">
<?php submit_button( __( 'Revoke all application passwords' ), 'delete', 'revoke-all-application-passwords', false ); ?>
<button type="button" name="revoke-all-application-passwords" id="revoke-all-application-passwords" class="button delete"><?php _e( 'Revoke all application passwords' ); ?></button>
</div>
<?php endif; ?>
<div class="alignleft actions bulkactions">
Expand Down Expand Up @@ -235,10 +233,10 @@ public function print_js_template_row() {
break;
case 'revoke':
printf(
'<input type="submit" class="button delete" value="%1$s" aria-label="%2$s">',
esc_attr__( 'Revoke' ),
'<button type="button" class="button delete" aria-label="%1$s">%2$s</button>',
/* translators: %s: the application password's given name. */
esc_attr( sprintf( __( 'Revoke "%s"' ), '{{ data.name }}' ) )
esc_attr( sprintf( __( 'Revoke "%s"' ), '{{ data.name }}' ) ),
esc_html__( 'Revoke' )
);
break;
default:
Expand Down
7 changes: 7 additions & 0 deletions wp-admin/js/application-passwords.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,13 @@
} );
} );

$newAppPassField.on( 'keypress', function ( e ) {
if ( 13 === e.which ) {
e.preventDefault();
$newAppPassButton.trigger( 'click' );
}
} );

// If there are no items, don't display the table yet. If there are, show it.
if ( 0 === $appPassTbody.children( 'tr' ).not( $appPassTrNoItems ).length ) {
$appPassTwrapper.hide();
Expand Down
2 changes: 1 addition & 1 deletion wp-admin/js/application-passwords.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion wp-admin/user-edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -780,7 +780,7 @@
do_action( 'wp_create_application_password_form', $profileuser );
?>

<?php submit_button( __( 'Add New Application Password' ), 'secondary', 'do_new_application_password' ); ?>
<button type="button" name="do_new_application_password" id="do_new_application_password" class="button button-secondary"><?php _e( 'Add New Application Password' ); ?></button>
</div>
<?php } else { ?>
<div class="notice notice-error inline">
Expand Down
2 changes: 1 addition & 1 deletion wp-includes/version.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*
* @global string $wp_version
*/
$wp_version = '5.8-alpha-51085';
$wp_version = '5.8-alpha-51086';

/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
Expand Down

0 comments on commit e53ace6

Please sign in to comment.