Make WordPress Core

Timestamp:
06/21/2024 06:15:50 PM (5 weeks ago)
Author:
joedolson
Message:

Administration: A11y: Add role="alert" on JS injected admin notices.

Add the attribute role="alert" on 12 instances of admin notices that are injected into the DOM using JavaScript. The role="alert" attribute allows screen readers to recognize the addition to the DOM and announce the errors to users.

Props afercia, cyrus11, rcreators, joedolson.
Fixes #47111.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/js/_enqueues/lib/ajax-response.js

    r53709 r58455  
    5454            } );
    5555            if ( err.length ) {
    56                 re.html( '<div class="notice notice-error">' + err + '</div>' );
     56                re.html( '<div class="notice notice-error">' + err + '</div>' );
    5757                wp.a11y.speak( err );
    5858            } else if ( noticeMessage.length ) {
    59                 re.html( '<div class="notice notice-success is-dismissible"><p>' + noticeMessage + '</p></div>');
     59                re.html( '<div class="notice notice-success is-dismissible"><p>' + noticeMessage + '</p></div>');
    6060                jQuery(document).trigger( 'wp-updates-notice-added' );
    6161                wp.a11y.speak( noticeMessage );
     
    6565        if ( isNaN( x ) ) {
    6666            wp.a11y.speak( x );
    67             return ! re.html( '<div class="notice notice-error"><p>' + x + '</p></div>' );
     67            return ! re.html( '<div class="notice notice-error"><p>' + x + '</p></div>' );
    6868        }
    6969        x = parseInt( x, 10 );
    7070        if ( -1 === x ) {
    7171            wp.a11y.speak( wpAjax.noPerm );
    72             return ! re.html( '<div class="notice notice-error"><p>' + wpAjax.noPerm + '</p></div>' );
     72            return ! re.html( '<div class="notice notice-error"><p>' + wpAjax.noPerm + '</p></div>' );
    7373        } else if ( 0 === x ) {
    7474            wp.a11y.speak( wpAjax.broken );
    75             return ! re.html( '<div class="notice notice-error"><p>' + wpAjax.broken  + '</p></div>' );
     75            return ! re.html( '<div class="notice notice-error"><p>' + wpAjax.broken  + '</p></div>' );
    7676        }
    7777        return true;
Note: See TracChangeset for help on using the changeset viewer.