From 6a7a92e0eae64caa189c18bcd8be8bd323de5ec1 Mon Sep 17 00:00:00 2001 From: "Dominik Schilling (ocean90)" Date: Sun, 29 Mar 2015 11:16:30 +0000 Subject: [PATCH] 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 --- src/wp-admin/js/customize-controls.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/wp-admin/js/customize-controls.js b/src/wp-admin/js/customize-controls.js index 86cb94954c..380a722591 100644 --- a/src/wp-admin/js/customize-controls.js +++ b/src/wp-admin/js/customize-controls.js @@ -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 );