Make WordPress Core


Ignore:
Timestamp:
07/07/2020 12:58:10 PM (6 years ago)
Author:
afercia
Message:

Accessibility: Allow post boxes on the Dashboard and Classic Editor pages to be reordered by using the keyboard.

So far, it has been possible to rearrange into a new order the post boxes (also known as "widgets" on the Dashboard and "meta boxes" on the Edit post page) only by using a pointing device, for example a mouse.

This change adds new controls and functionality to allow the boxes to be rearranged also with the keyboard. Additionally, audible messages are sent to the admin ARIA live region to notify screen reader users of the reorder action result.

Props joedolson, anevins, antpb, audrasjb, xkon, MarcoZ, karmatosed, afercia.
Fixes #39074.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/template.php

    r48199 r48373  
    13151315                                        $hidden_class = ( ! $screen->is_block_editor() && in_array( $box['id'], $hidden, true ) ) ? ' hide-if-js' : '';
    13161316                                        echo '<div id="' . $box['id'] . '" class="postbox ' . postbox_classes( $box['id'], $page ) . $hidden_class . '" ' . '>' . "\n";
     1317
     1318                                        echo '<div class="postbox-header">';
     1319                                        echo '<h2 class="hndle">';
     1320                                        if ( 'dashboard_php_nag' === $box['id'] ) {
     1321                                                echo '<span aria-hidden="true" class="dashicons dashicons-warning"></span>';
     1322                                                echo '<span class="screen-reader-text">' . __( 'Warning:' ) . ' </span>';
     1323                                        }
     1324                                        echo "{$box['title']}";
     1325                                        echo "</h2>\n";
     1326
    13171327                                        if ( 'dashboard_browser_nag' !== $box['id'] ) {
    13181328                                                $widget_title = $box['title'];
    … …  
    13231333                                                        unset( $box['args']['__widget_basename'] );
    13241334                                                }
     1335
     1336                                                echo '<div class="handle-actions hide-if-no-js">';
     1337
     1338                                                echo '<button type="button" class="handle-order-higher" aria-disabled="false" aria-describedby="' . $box['id'] . '-handle-order-higher-description">';
     1339                                                echo '<span class="screen-reader-text">' . __( 'Move up' ) . '</span>';
     1340                                                echo '<span class="order-higher-indicator" aria-hidden="true"></span>';
     1341                                                echo '</button>';
     1342                                                echo '<span class="hidden" id="' . $box['id'] . '-handle-order-higher-description">' . sprintf(
     1343                                                        /* translators: %s: Meta box title. */
     1344                                                        __( 'Move %s box up' ),
     1345                                                        $widget_title
     1346                                                ) . '</span>';
     1347
     1348                                                echo '<button type="button" class="handle-order-lower" aria-disabled="false" aria-describedby="' . $box['id'] . '-handle-order-lower-description">';
     1349                                                echo '<span class="screen-reader-text">' . __( 'Move down' ) . '</span>';
     1350                                                echo '<span class="order-lower-indicator" aria-hidden="true"></span>';
     1351                                                echo '</button>';
     1352                                                echo '<span class="hidden" id="' . $box['id'] . '-handle-order-lower-description">' . sprintf(
     1353                                                        /* translators: %s: Meta box title. */
     1354                                                        __( 'Move %s box down' ),
     1355                                                        $widget_title
     1356                                                ) . '</span>';
    13251357
    13261358                                                echo '<button type="button" class="handlediv" aria-expanded="true">';
    … …  
    13321364                                                echo '<span class="toggle-indicator" aria-hidden="true"></span>';
    13331365                                                echo '</button>';
     1366
     1367                                                echo '</div>';
    13341368                                        }
    1335                                         echo '<h2 class="hndle">';
    1336                                         if ( 'dashboard_php_nag' === $box['id'] ) {
    1337                                                 echo '<span aria-hidden="true" class="dashicons dashicons-warning"></span>';
    1338                                                 echo '<span class="screen-reader-text">' . __( 'Warning:' ) . ' </span>';
    1339                                         }
    1340                                         echo "<span>{$box['title']}</span>";
    1341                                         echo "</h2>\n";
     1369                                        echo '</div>';
     1370
    13421371                                        echo '<div class="inside">' . "\n";
    13431372
Note: See TracChangeset for help on using the changeset viewer.