Make WordPress Core

Changeset 56602


Ignore:
Timestamp:
09/17/2023 10:49:06 PM (9 months ago)
Author:
joedolson
Message:

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.

Location:
trunk/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/js/_enqueues/admin/application-passwords.js

    r51086 r56602  
    6161                password: response.password
    6262            } ) );
    63             $( '.new-application-password-notice' ).trigger( 'focus' );
     63            $( '.new-application-password-notice' ).attr( 'tabindex', '-1' ).trigger( 'focus' );
    6464
    6565            $appPassTbody.prepend( tmplAppPassRow( response ) );
  • trunk/src/js/_enqueues/lib/image-edit.js

    r56591 r56602  
    859859            }
    860860
    861             elementToSetFocusTo.trigger( 'focus' );
     861            elementToSetFocusTo.attr( 'tabindex', '-1' ).trigger( 'focus' );
    862862        }, 100 );
    863863    },
  • trunk/src/wp-admin/includes/image-edit.php

    r56549 r56602  
    4040    if ( $msg ) {
    4141        if ( isset( $msg->error ) ) {
    42             $note = "<div class='notice notice-error' tabindex='-1' role='alert'><p>$msg->error</p></div>";
     42            $note = "<div class='notice notice-error' role='alert'><p>$msg->error</p></div>";
    4343        } elseif ( isset( $msg->msg ) ) {
    44             $note = "<div class='notice notice-success' tabindex='-1' role='alert'><p>$msg->msg</p></div>";
     44            $note = "<div class='notice notice-success' role='alert'><p>$msg->msg</p></div>";
    4545        }
    4646    }
  • trunk/src/wp-admin/user-edit.php

    r56600 r56602  
    966966<?php if ( isset( $application_passwords_list_table ) ) : ?>
    967967    <script type="text/html" id="tmpl-new-application-password">
    968         <div class="notice notice-success is-dismissible new-application-password-notice" role="alert" tabindex="-1">
     968        <div class="notice notice-success is-dismissible new-application-password-notice" role="alert">
    969969            <p class="application-password-display">
    970970                <label for="new-application-password-value">
Note: See TracChangeset for help on using the changeset viewer.