Make WordPress Core

Changeset 59225


Ignore:
Timestamp:
10/13/2024 08:47:12 PM (2 years ago)
Author:
joedolson
Message:

Revisions: Improve accessibility of revisions selection.

Add aria-labelledby and aria-describedby attributes to revision slider selection handle. Add keyboard :focus state to revision slider handle. Move 'multiple revision' checkbox before the buttons panel, matching its visual order. Change diff Title and Content headings from h3 to h2 to correct headings hierarchy.

Props joedolson, rishishah, sarahricker, williamalexander, afercia.
Fixes #52303.

Location:
trunk/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/js/_enqueues/wp/revisions.js

    r47120 r59225  
    596596                        _.bindAll( this, 'setWidth' );
    597597
     598                        // Add the checkbox view.
     599                        this.views.add( new revisions.view.Checkbox({
     600                                model: this.model
     601                        }) );
     602
    598603                        // Add the button view.
    599604                        this.views.add( new revisions.view.Buttons({
    600                                 model: this.model
    601                         }) );
    602 
    603                         // Add the checkbox view.
    604                         this.views.add( new revisions.view.Checkbox({
    605605                                model: this.model
    606606                        }) );
    … …  
    628628                                model: tooltip
    629629                        }) );
     630
     631                        // Add the visually hidden slider help view.
     632                        this.views.add( new revisions.view.SliderHelp() );
    630633
    631634                        // Add the slider view.
    … …  
    805808        });
    806809
     810        // The slider visually hidden help view.
     811        revisions.view.SliderHelp = wp.Backbone.View.extend({
     812                className: 'revisions-slider-hidden-help',
     813                template:  wp.template( 'revisions-slider-hidden-help' )
     814        });
     815   
    807816        // The tooltip view.
    808817        // Encapsulates the tooltip.
    … …  
    958967                },
    959968
     969                accessibilityHelper: function() {
     970                        var handles = $( '.ui-slider-handle' );
     971                        handles.first().attr( {
     972                                        role: 'button',
     973                                        'aria-labelledby': 'diff-title-from diff-title-author',
     974                                        'aria-describedby': 'revisions-slider-hidden-help',
     975                        } );
     976                        handles.last().attr( {
     977                                        role: 'button',
     978                                        'aria-labelledby': 'diff-title-to diff-title-author',
     979                                        'aria-describedby': 'revisions-slider-hidden-help',
     980                        } );
     981                },
     982
    960983                mouseMove: function( e ) {
    961984                        var zoneCount         = this.model.revisions.length - 1,       // One fewer zone than models.
    … …  
    9971020                                        .toggleClass( 'from-handle', !! isRtl )
    9981021                                        .toggleClass( 'to-handle', ! isRtl );
     1022                                this.accessibilityHelper();
    9991023                        } else {
    10001024                                handles.removeClass('from-handle to-handle');
    1001                         }
     1025                                this.accessibilityHelper();
     1026                        }
     1027
    10021028                },
    10031029
  • trunk/src/wp-admin/css/revisions.css

    r57363 r59225  
    459459}
    460460
    461 .wp-slider .ui-slider-handle,
    462 .wp-slider .ui-slider-handle.focus {
     461.wp-slider .ui-slider-handle {
    463462        background: #f6f7f7;
    464463        border: 1px solid #c3c4c7;
    … …  
    478477        box-shadow: inset 0 2px 5px -3px rgba(0, 0, 0, 0.5);
    479478        transform: translateY(1px);
     479}
     480
     481.wp-slider .ui-slider-handle:focus,
     482.wp-slider .ui-slider-handle.ui-state-focus {
     483        background: #f0f0f1;
     484        border-color: #8c8f94;
     485        box-shadow: 0 0 0 2px #2271b1;
     486        /* Only visible in Windows High Contrast mode */
     487        outline: 2px solid transparent;
    480488}
    481489
  • trunk/src/wp-admin/includes/revision.php

    r57644 r59225  
    379379        </script>
    380380
     381        <script id="tmpl-revisions-slider-hidden-help" type="text/html">
     382                <h2 class="screen-reader-text"><?php esc_html_e( 'Select a revision' ); ?></h2>
     383                <p id="revisions-slider-hidden-help" hidden><?php esc_html_e( 'Change revision by using the left and arrow keys' ); ?></p>
     384        </script>
     385
    381386        <script id="tmpl-revisions-checkbox" type="text/html">
    382387                <div class="revision-toggle-compare-mode">
    … …  
    398403                        <div class="diff-title">
    399404                                <# if ( 'from' === data.type ) { #>
    400                                         <strong><?php _ex( 'From:', 'Followed by post revision info' ); ?></strong>
     405                                        <strong id="diff-title-from"><?php _ex( 'From:', 'Followed by post revision info' ); ?></strong>
    401406                                <# } else if ( 'to' === data.type ) { #>
    402                                         <strong><?php _ex( 'To:', 'Followed by post revision info' ); ?></strong>
     407                                        <strong id="diff-title-to"><?php _ex( 'To:', 'Followed by post revision info' ); ?></strong>
    403408                                <# } #>
    404409                                <div class="author-card<# if ( data.attributes.autosave ) { #> autosave<# } #>">
    405410                                        {{{ data.attributes.author.avatar }}}
    406                                         <div class="author-info">
     411                                        <div class="author-info" id="diff-title-author">
    407412                                        <# if ( data.attributes.autosave ) { #>
    408413                                                <span class="byline">
    … …  
    465470                <div class="diff">
    466471                <# _.each( data.fields, function( field ) { #>
    467                         <h3>{{ field.name }}</h3>
     472                        <h2>{{ field.name }}</h2>
    468473                        {{{ field.diff }}}
    469474                <# }); #>
Note: See TracChangeset for help on using the changeset viewer.