From 5b7424510833f72ba55cc91f88ec1d316806f74b Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Tue, 4 Apr 2017 06:51:39 +0000 Subject: [PATCH] Customize: Fix failure to collapse expanded sections and panels that become deactivated. Improve jsdoc for `onChangeActive` function. Restores fix from [34557] which got dropped in [38648]. Props dlh, westonruter. See #34391, #33509. Fixes #39430. Merges [40304] to the 4.7 branch. git-svn-id: https://develop.svn.wordpress.org/branches/4.7@40375 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/js/customize-controls.js | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/wp-admin/js/customize-controls.js b/src/wp-admin/js/customize-controls.js index f6d7359fc4..e8f19dd7c7 100644 --- a/src/wp-admin/js/customize-controls.js +++ b/src/wp-admin/js/customize-controls.js @@ -528,10 +528,11 @@ * * @since 4.1.0 * - * @param {Boolean} active - * @param {Object} args - * @param {Object} args.duration - * @param {Object} args.completeCallback + * @param {boolean} active - The active state to transiution to. + * @param {Object} [args] - Args. + * @param {Object} [args.duration] - The duration for the slideUp/slideDown animation. + * @param {boolean} [args.unchanged] - Whether the state is already known to not be changed, and so short-circuit with calling completeCallback early. + * @param {Function} [args.completeCallback] - Function to call when the slideUp/slideDown has completed. */ onChangeActive: function( active, args ) { var construct = this, @@ -564,24 +565,24 @@ } } - if ( ! $.contains( document, headContainer ) ) { - // jQuery.fn.slideUp is not hiding an element if it is not in the DOM + if ( ! $.contains( document, headContainer.get( 0 ) ) ) { + // If the element is not in the DOM, then jQuery.fn.slideUp() does nothing. In this case, a hard toggle is required instead. headContainer.toggle( active ); if ( args.completeCallback ) { args.completeCallback(); } } else if ( active ) { - headContainer.stop( true, true ).slideDown( duration, args.completeCallback ); + headContainer.slideDown( duration, args.completeCallback ); } else { if ( construct.expanded() ) { construct.collapse({ duration: duration, completeCallback: function() { - headContainer.stop( true, true ).slideUp( duration, args.completeCallback ); + headContainer.slideUp( duration, args.completeCallback ); } }); } else { - headContainer.stop( true, true ).slideUp( duration, args.completeCallback ); + headContainer.slideUp( duration, args.completeCallback ); } } },