From bad2471fa9bca0205e4297bf695d0afc9fe11300 Mon Sep 17 00:00:00 2001 From: Joe Dolson Date: Mon, 7 Jun 2021 23:48:18 +0000 Subject: [PATCH] Application Passwords: Allow enter key to submit profile form. 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. git-svn-id: https://develop.svn.wordpress.org/trunk@51086 602fd350-edb4-49c9-b593-d223f7449a82 --- .../_enqueues/admin/application-passwords.js | 7 ++++++ ...ss-wp-application-passwords-list-table.php | 24 +++++++++---------- src/wp-admin/user-edit.php | 2 +- 3 files changed, 19 insertions(+), 14 deletions(-) diff --git a/src/js/_enqueues/admin/application-passwords.js b/src/js/_enqueues/admin/application-passwords.js index 622597e5a8..ae9fe43b0c 100644 --- a/src/js/_enqueues/admin/application-passwords.js +++ b/src/js/_enqueues/admin/application-passwords.js @@ -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(); diff --git a/src/wp-admin/includes/class-wp-application-passwords-list-table.php b/src/wp-admin/includes/class-wp-application-passwords-list-table.php index c8055e00e5..88bafa3b00 100644 --- a/src/wp-admin/includes/class-wp-application-passwords-list-table.php +++ b/src/wp-admin/includes/class-wp-application-passwords-list-table.php @@ -110,15 +110,13 @@ class WP_Application_Passwords_List_Table extends WP_List_Table { * @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( + '', + esc_attr( $name ), + /* translators: %s: the application password's given name. */ + esc_attr( sprintf( __( 'Revoke "%s"' ), $item['name'] ) ), + __( 'Revoke' ) ); } @@ -156,7 +154,7 @@ class WP_Application_Passwords_List_Table extends WP_List_Table {
- +
@@ -235,10 +233,10 @@ class WP_Application_Passwords_List_Table extends WP_List_Table { break; case 'revoke': printf( - '', - esc_attr__( 'Revoke' ), + '', /* 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: diff --git a/src/wp-admin/user-edit.php b/src/wp-admin/user-edit.php index 71e16072dc..c994d7e965 100644 --- a/src/wp-admin/user-edit.php +++ b/src/wp-admin/user-edit.php @@ -780,7 +780,7 @@ endif; do_action( 'wp_create_application_password_form', $profileuser ); ?> - +