Skip to content

Commit

Permalink
Accessibility: Improve the Themes Installer navigation buttons access…
Browse files Browse the repository at this point in the history
…ibility.

- really disables buttons when they look disabled (when navigation is at the first or last theme)
- when navigation is at the first or last theme, moves focus to the other navigation button, to avoid a focus loss
- improves the buttons visually hidden accessibility text

Props walbo, afercia.
Fixes #36627.


git-svn-id: https://develop.svn.wordpress.org/trunk@43020 602fd350-edb4-49c9-b593-d223f7449a82
  • Loading branch information
afercia committed Apr 29, 2018
1 parent 75ca3d6 commit 52e28b4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
16 changes: 13 additions & 3 deletions src/wp-admin/js/theme.js
Expand Up @@ -573,16 +573,26 @@ themes.view.Theme = wp.Backbone.View.extend({
// Handles .disabled classes for previous/next buttons in theme installer preview
setNavButtonsState: function() {
var $themeInstaller = $( '.theme-install-overlay' ),
current = _.isUndefined( this.current ) ? this.model : this.current;
current = _.isUndefined( this.current ) ? this.model : this.current,
previousThemeButton = $themeInstaller.find( '.previous-theme' ),
nextThemeButton = $themeInstaller.find( '.next-theme' );

// Disable previous at the zero position
if ( 0 === this.model.collection.indexOf( current ) ) {
$themeInstaller.find( '.previous-theme' ).addClass( 'disabled' );
previousThemeButton
.addClass( 'disabled' )
.prop( 'disabled', true );

nextThemeButton.focus();
}

// Disable next if the next model is undefined
if ( _.isUndefined( this.model.collection.at( this.model.collection.indexOf( current ) + 1 ) ) ) {
$themeInstaller.find( '.next-theme' ).addClass( 'disabled' );
nextThemeButton
.addClass( 'disabled' )
.prop( 'disabled', true );

previousThemeButton.focus();
}
},

Expand Down
4 changes: 2 additions & 2 deletions src/wp-admin/theme-install.php
Expand Up @@ -309,8 +309,8 @@
<div class="wp-full-overlay-sidebar">
<div class="wp-full-overlay-header">
<button class="close-full-overlay"><span class="screen-reader-text"><?php _e( 'Close' ); ?></span></button>
<button class="previous-theme"><span class="screen-reader-text"><?php _ex( 'Previous', 'Button label for a theme' ); ?></span></button>
<button class="next-theme"><span class="screen-reader-text"><?php _ex( 'Next', 'Button label for a theme' ); ?></span></button>
<button class="previous-theme"><span class="screen-reader-text"><?php _e( 'Previous theme' ); ?></span></button>
<button class="next-theme"><span class="screen-reader-text"><?php _e( 'Next theme' ); ?></span></button>
<# if ( data.installed ) { #>
<a class="button button-primary activate" href="{{ data.activate_url }}"><?php _e( 'Activate' ); ?></a>
<# } else { #>
Expand Down

0 comments on commit 52e28b4

Please sign in to comment.