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.

git-svn-id: https://develop.svn.wordpress.org/trunk@31920 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Dominik Schilling (ocean90) 2015-03-29 11:16:30 +00:00
parent 034a4f20f0
commit 6a7a92e0ea
1 changed files with 11 additions and 4 deletions

View File

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