Customizer: Fix calculation of panel positions when accessing via deep-links.

Make sure that the parent `li` is shown before attempting to calculate its position.
Improve also the logic for focusing on a panel to prevent focusing hidden elements.

props westonruter.
fixes #31014.
see #31794.
Built from https://develop.svn.wordpress.org/trunk@31920


git-svn-id: http://core.svn.wordpress.org/trunk@31899 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Dominik Schilling 2015-03-29 11:17:28 +00:00
parent 71f48f45e0
commit b07e3e2de7
3 changed files with 14 additions and 7 deletions

View File

@ -67,8 +67,14 @@
construct = this; construct = this;
params = params || {}; params = params || {};
focus = function () { focus = function () {
construct.container.find( ':focusable:first' ).focus(); var focusContainer;
construct.container[0].scrollIntoView( true ); if ( construct.extended( api.Panel ) && construct.expanded() ) {
focusContainer = construct.container.find( '.control-panel-content:first' );
} else {
focusContainer = construct.container;
}
focusContainer.find( ':focusable:first' ).focus();
focusContainer[0].scrollIntoView( true );
}; };
if ( params.completeCallback ) { if ( params.completeCallback ) {
completeCallback = params.completeCallback; completeCallback = params.completeCallback;
@ -715,7 +721,7 @@
content.show( 0, function() { content.show( 0, function() {
position = content.offset().top; position = content.offset().top;
scroll = container.scrollTop(); scroll = container.scrollTop();
content.css( 'margin-top', ( 45 - position - scroll ) ); content.css( 'margin-top', ( $( '#customize-header-actions' ).height() - position - scroll ) );
section.addClass( 'current-panel' ); section.addClass( 'current-panel' );
overlay.addClass( 'in-themes-panel' ); overlay.addClass( 'in-themes-panel' );
container.scrollTop( 0 ); container.scrollTop( 0 );
@ -1039,9 +1045,10 @@
}); });
content.show( 0, function() { content.show( 0, function() {
content.parent().show();
position = content.offset().top; position = content.offset().top;
scroll = container.scrollTop(); scroll = container.scrollTop();
content.css( 'margin-top', ( 45 - position - scroll ) ); content.css( 'margin-top', ( $( '#customize-header-actions' ).height() - position - scroll ) );
section.addClass( 'current-panel' ); section.addClass( 'current-panel' );
overlay.addClass( 'in-sub-panel' ); overlay.addClass( 'in-sub-panel' );
container.scrollTop( 0 ); container.scrollTop( 0 );

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.2-beta3-31919'; $wp_version = '4.2-beta3-31920';
/** /**
* 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.