Make WordPress Core

Changeset 32743


Ignore:
Timestamp:
06/12/2015 10:27:51 PM (10 years ago)
Author:
westonruter
Message:

Fix regressions from [32649] wrt Customizer expanded and active state changes for sections.

The args.completeCallback was not always called when onChangeExpanded() was called. And when a section became inactive (active state goes to false) and it was currently expanded, the Customizer panel would then becomes blank as the section was hidden; it needed to collapse() the section first before hiding the element.

See #31336.

File:
1 edited

Legend:

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

    r32681 r32743  
    285285         */
    286286        onChangeActive: function ( active, args ) {
    287             var duration = ( 'resolved' === api.previewer.deferred.active.state() ? args.duration : 0 );
    288             if ( ! $.contains( document, this.container ) ) {
     287            var duration, construct = this;
     288            duration = ( 'resolved' === api.previewer.deferred.active.state() ? args.duration : 0 );
     289            if ( ! $.contains( document, construct.container[0] ) ) {
    289290                // jQuery.fn.slideUp is not hiding an element if it is not in the DOM
    290                 this.container.toggle( active );
     291                construct.container.toggle( active );
    291292                if ( args.completeCallback ) {
    292293                    args.completeCallback();
    293294                }
    294295            } else if ( active ) {
    295                 this.container.stop( true, true ).slideDown( duration, args.completeCallback );
     296                construct.container.stop( true, true ).slideDown( duration, args.completeCallback );
    296297            } else {
    297                 this.container.stop( true, true ).slideUp( duration, args.completeCallback );
     298                if ( construct.expanded() ) {
     299                    construct.collapse({
     300                        duration: duration,
     301                        completeCallback: function() {
     302                            construct.container.stop( true, true ).slideUp( duration, args.completeCallback );
     303                        }
     304                    });
     305                } else {
     306                    construct.container.stop( true, true ).slideUp( duration, args.completeCallback );
     307                }
    298308            }
    299309        },
     
    597607                        scroll = container.scrollTop();
    598608                        content.css( 'margin-top', ( 45 - position - scroll ) );
     609                        if ( args.completeCallback ) {
     610                            args.completeCallback();
     611                        }
    599612                    };
    600613                }
     
    617630                }
    618631
    619             } else if ( section.container.hasClass( 'open' ) ) {
     632            } else if ( ! expanded && section.container.hasClass( 'open' ) ) {
    620633                section.container.removeClass( 'open' );
    621634                overlay.removeClass( 'section-open' );
     
    623636                container.scrollTop( 0 );
    624637                section.container.find( '.accordion-section-title' ).focus();
     638                if ( args.completeCallback ) {
     639                    args.completeCallback();
     640                }
     641            } else {
     642                if ( args.completeCallback ) {
     643                    args.completeCallback();
     644                }
    625645            }
    626646        }
Note: See TracChangeset for help on using the changeset viewer.