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/admin/user-profile.js

    r58145 r58455  
    152152     */
    153153    function addInlineNotice( $this, success, message ) {
    154         var resultDiv = $( '<div />' );
     154        var resultDiv = $( '<div />', {
     155            role: 'alert'
     156        } );
    155157
    156158        // Set up the notice div.
     
    475477            $this.prop( 'disabled', true );
    476478            $this.siblings( '.notice' ).remove();
    477             $this.before( '<div class="notice notice-success inline"><p>' + response.message + '</p></div>' );
     479            $this.before( '<div class="notice notice-success inline"><p>' + response.message + '</p></div>' );
    478480        }).fail( function( response ) {
    479481            $this.siblings( '.notice' ).remove();
    480             $this.before( '<div class="notice notice-error inline"><p>' + response.message + '</p></div>' );
     482            $this.before( '<div class="notice notice-error inline"><p>' + response.message + '</p></div>' );
    481483        });
    482484
Note: See TracChangeset for help on using the changeset viewer.