Customizer: Defer updating nav menu item `tabIndex` attributes until pane is reflowed.

Introduces `pane-contents-reflowed` Customizer event.

Props valendesigns, westonruter.
Fixes #32943.

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


git-svn-id: http://core.svn.wordpress.org/trunk@33255 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Weston Ruter 2015-07-15 20:05:25 +00:00
parent 8c9eb43d47
commit 0f37c66077
5 changed files with 17 additions and 11 deletions

View File

@ -3234,6 +3234,7 @@
if ( wasReflowed && activeElement ) { if ( wasReflowed && activeElement ) {
activeElement.focus(); activeElement.focus();
} }
api.trigger( 'pane-contents-reflowed' );
}, api ); }, api );
api.bind( 'ready', api.reflowPaneContents ); api.bind( 'ready', api.reflowPaneContents );
api.reflowPaneContents = _.debounce( api.reflowPaneContents, 100 ); api.reflowPaneContents = _.debounce( api.reflowPaneContents, 100 );

File diff suppressed because one or more lines are too long

View File

@ -673,6 +673,18 @@
}); });
section.refreshAssignedLocations(); section.refreshAssignedLocations();
api.bind( 'pane-contents-reflowed', function() {
// Skip menus that have been removed.
if ( ! section.container.parent().length ) {
return;
}
section.container.find( '.menu-item .menu-item-reorder-nav button' ).prop( 'tabIndex', 0 );
section.container.find( '.menu-item.move-up-disabled .menus-move-up' ).prop( 'tabIndex', -1 );
section.container.find( '.menu-item.move-down-disabled .menus-move-down' ).prop( 'tabIndex', -1 );
section.container.find( '.menu-item.move-left-disabled .menus-move-left' ).prop( 'tabIndex', -1 );
section.container.find( '.menu-item.move-right-disabled .menus-move-right' ).prop( 'tabIndex', -1 );
} );
}, },
populateControls: function() { populateControls: function() {
@ -2031,7 +2043,6 @@
*/ */
reflowMenuItems: function() { reflowMenuItems: function() {
var menuControl = this, var menuControl = this,
menuSection = api.section( 'nav_menu[' + String( menuControl.params.menu_id ) + ']' ),
menuItemControls = menuControl.getMenuItemControls(), menuItemControls = menuControl.getMenuItemControls(),
reflowRecursively; reflowRecursively;
@ -2098,12 +2109,6 @@
currentAbsolutePosition: 0 currentAbsolutePosition: 0
} ); } );
menuSection.container.find( '.menu-item .menu-item-reorder-nav button' ).prop( 'tabIndex', 0 );
menuSection.container.find( '.menu-item.move-up-disabled .menus-move-up' ).prop( 'tabIndex', -1 );
menuSection.container.find( '.menu-item.move-down-disabled .menus-move-down' ).prop( 'tabIndex', -1 );
menuSection.container.find( '.menu-item.move-left-disabled .menus-move-left' ).prop( 'tabIndex', -1 );
menuSection.container.find( '.menu-item.move-right-disabled .menus-move-right' ).prop( 'tabIndex', -1 );
menuControl.container.find( '.reorder-toggle' ).toggle( menuItemControls.length > 1 ); menuControl.container.find( '.reorder-toggle' ).toggle( menuItemControls.length > 1 );
}, },

File diff suppressed because one or more lines are too long

View File

@ -4,7 +4,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '4.3-beta2-33282'; $wp_version = '4.3-beta2-33283';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.