Accessibility: Customize: Improve the widgets search and the widget Remove button.

- debounces the widgets search to avoid multiple `speak()` audible messages while typing: search results and messages are now triggered when users stop typing
- clarifies the Remove button title attribute
- removes a couple unnecessary `preventDefault()`

Props davetgreen, afercia.
Fixes #28888.

Built from https://develop.svn.wordpress.org/trunk@44825


git-svn-id: http://core.svn.wordpress.org/trunk@44657 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Andrea Fercia 2019-03-09 12:56:54 +00:00
parent 26ab5fcee1
commit 9e67a186a5
4 changed files with 9 additions and 12 deletions

View File

@ -203,7 +203,7 @@
/**
* Performs a search and handles selected widget.
*/
search: function( event ) {
search: _.debounce( function( event ) {
var firstVisible;
this.collection.doSearch( event.target.value );
@ -245,7 +245,7 @@
} else {
this.$el.removeClass( 'no-widgets-found' );
}
},
}, 500 ),
/**
* Updates the count of the available widgets that have the `search_matched` attribute.
@ -257,7 +257,7 @@
/**
* Sends a message to the aria-live region to announce how many search results.
*/
announceSearchMatches: _.debounce( function() {
announceSearchMatches: function() {
var message = l10n.widgetsFound.replace( '%d', this.searchMatchesCount ) ;
if ( ! this.searchMatchesCount ) {
@ -265,7 +265,7 @@
}
wp.a11y.speak( message );
}, 500 ),
},
/**
* Changes visibility of available widgets.
@ -708,8 +708,7 @@
} );
$closeBtn = this.container.find( '.widget-control-close' );
$closeBtn.on( 'click', function( e ) {
e.preventDefault();
$closeBtn.on( 'click', function() {
self.collapse();
self.container.find( '.widget-top .widget-action:first' ).focus(); // keyboard accessibility
} );
@ -987,9 +986,7 @@
// Configure remove button
$removeBtn = this.container.find( '.widget-control-remove' );
$removeBtn.on( 'click', function( e ) {
e.preventDefault();
$removeBtn.on( 'click', function() {
// Find an adjacent element to add focus to when this widget goes away
var $adjacentFocusTarget;
if ( self.container.next().is( '.customize-control-widget_form' ) ) {

File diff suppressed because one or more lines are too long

View File

@ -777,7 +777,7 @@ final class WP_Customize_Widgets {
'saveBtnLabel' => __( 'Apply' ),
'saveBtnTooltip' => __( 'Save and preview changes before publishing them.' ),
'removeBtnLabel' => __( 'Remove' ),
'removeBtnTooltip' => __( 'Trash widget by moving it to the inactive widgets sidebar.' ),
'removeBtnTooltip' => __( 'Keep widget settings and move it to the inactive widgets' ),
'error' => __( 'An error has occurred. Please reload the page and try again.' ),
'widgetMovedUp' => __( 'Widget moved up' ),
'widgetMovedDown' => __( 'Widget moved down' ),

View File

@ -13,7 +13,7 @@
*
* @global string $wp_version
*/
$wp_version = '5.2-alpha-44824';
$wp_version = '5.2-alpha-44825';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.