WordPress.org

Make WordPress Core

Changeset 31920


Ignore:
Timestamp:
03/29/2015 11:16:30 AM (5 years ago)
Author:
ocean90
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/js/customize-controls.js

    r31918 r31920  
    6868        params = params || {};
    6969        focus = function () {
    70             construct.container.find( ':focusable:first' ).focus();
    71             construct.container[0].scrollIntoView( true );
     70            var focusContainer;
     71            if ( construct.extended( api.Panel ) && construct.expanded() ) {
     72                focusContainer = construct.container.find( '.control-panel-content:first' );
     73            } else {
     74                focusContainer = construct.container;
     75            }
     76            focusContainer.find( ':focusable:first' ).focus();
     77            focusContainer[0].scrollIntoView( true );
    7278        };
    7379        if ( params.completeCallback ) {
     
    716722                    position = content.offset().top;
    717723                    scroll = container.scrollTop();
    718                     content.css( 'margin-top', ( 45 - position - scroll ) );
     724                    content.css( 'margin-top', ( $( '#customize-header-actions' ).height() - position - scroll ) );
    719725                    section.addClass( 'current-panel' );
    720726                    overlay.addClass( 'in-themes-panel' );
     
    10401046
    10411047                content.show( 0, function() {
     1048                    content.parent().show();
    10421049                    position = content.offset().top;
    10431050                    scroll = container.scrollTop();
    1044                     content.css( 'margin-top', ( 45 - position - scroll ) );
     1051                    content.css( 'margin-top', ( $( '#customize-header-actions' ).height() - position - scroll ) );
    10451052                    section.addClass( 'current-panel' );
    10461053                    overlay.addClass( 'in-sub-panel' );
Note: See TracChangeset for help on using the changeset viewer.