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
This commit is contained in:
Joe Dolson
2023-09-17 22:49:06 +00:00
parent 1e11c3fce8
commit 4e0e46018d
4 changed files with 5 additions and 5 deletions

View File

@@ -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 ) );

View File

@@ -858,7 +858,7 @@
elementToSetFocusTo = $( '.imgedit-wrap' ).find( ':tabbable:first' );
}
elementToSetFocusTo.trigger( 'focus' );
elementToSetFocusTo.attr( 'tabindex', '-1' ).trigger( 'focus' );
}, 100 );
},

View File

@@ -39,9 +39,9 @@ function wp_image_editor( $post_id, $msg = false ) {
if ( $msg ) {
if ( isset( $msg->error ) ) {
$note = "<div class='notice notice-error' tabindex='-1' role='alert'><p>$msg->error</p></div>";
$note = "<div class='notice notice-error' role='alert'><p>$msg->error</p></div>";
} elseif ( isset( $msg->msg ) ) {
$note = "<div class='notice notice-success' tabindex='-1' role='alert'><p>$msg->msg</p></div>";
$note = "<div class='notice notice-success' role='alert'><p>$msg->msg</p></div>";
}
}

View File

@@ -965,7 +965,7 @@ switch ( $action ) {
<?php if ( isset( $application_passwords_list_table ) ) : ?>
<script type="text/html" id="tmpl-new-application-password">
<div class="notice notice-success is-dismissible new-application-password-notice" role="alert" tabindex="-1">
<div class="notice notice-success is-dismissible new-application-password-notice" role="alert">
<p class="application-password-display">
<label for="new-application-password-value">
<?php