From 4e0e46018d158f68f9a9b1c6fea9c52fb8d76c42 Mon Sep 17 00:00:00 2001 From: Joe Dolson Date: Sun, 17 Sep 2023 22:49:06 +0000 Subject: [PATCH] Administration: Move `tabindex="-1"` from notice to JS. In a handful of admin notices, a `tabindex` attribute is set so that JS can move focus to the notice `div`. Rather than adding `tabindex` to globally accepted attributes for `wp_kses_post()`, move the assignment of `tabindex` into the JS handlers that display those notices. The attribute is only relevant if JS is running, so there is no reason to add it in the original HTML notice. Follow up to [56408], [56409], [56410], [56518], [56570], [56571], [56572], [56573], [56576], [56589], [56590], [56597], [56599], [56600], [56601]. Props costdev, joedolson. See #57791. git-svn-id: https://develop.svn.wordpress.org/trunk@56602 602fd350-edb4-49c9-b593-d223f7449a82 --- src/js/_enqueues/admin/application-passwords.js | 2 +- src/js/_enqueues/lib/image-edit.js | 2 +- src/wp-admin/includes/image-edit.php | 4 ++-- src/wp-admin/user-edit.php | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/js/_enqueues/admin/application-passwords.js b/src/js/_enqueues/admin/application-passwords.js index ae9fe43b0c..c79cdb8b40 100644 --- a/src/js/_enqueues/admin/application-passwords.js +++ b/src/js/_enqueues/admin/application-passwords.js @@ -60,7 +60,7 @@ name: response.name, password: response.password } ) ); - $( '.new-application-password-notice' ).trigger( 'focus' ); + $( '.new-application-password-notice' ).attr( 'tabindex', '-1' ).trigger( 'focus' ); $appPassTbody.prepend( tmplAppPassRow( response ) ); diff --git a/src/js/_enqueues/lib/image-edit.js b/src/js/_enqueues/lib/image-edit.js index f1e63a0157..253152b07b 100644 --- a/src/js/_enqueues/lib/image-edit.js +++ b/src/js/_enqueues/lib/image-edit.js @@ -858,7 +858,7 @@ elementToSetFocusTo = $( '.imgedit-wrap' ).find( ':tabbable:first' ); } - elementToSetFocusTo.trigger( 'focus' ); + elementToSetFocusTo.attr( 'tabindex', '-1' ).trigger( 'focus' ); }, 100 ); }, diff --git a/src/wp-admin/includes/image-edit.php b/src/wp-admin/includes/image-edit.php index 4e97e90aca..8281221eb2 100644 --- a/src/wp-admin/includes/image-edit.php +++ b/src/wp-admin/includes/image-edit.php @@ -39,9 +39,9 @@ function wp_image_editor( $post_id, $msg = false ) { if ( $msg ) { if ( isset( $msg->error ) ) { - $note = ""; + $note = ""; } elseif ( isset( $msg->msg ) ) { - $note = ""; + $note = ""; } } diff --git a/src/wp-admin/user-edit.php b/src/wp-admin/user-edit.php index 642b0185c4..d9b630e058 100644 --- a/src/wp-admin/user-edit.php +++ b/src/wp-admin/user-edit.php @@ -965,7 +965,7 @@ switch ( $action ) {