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.

Built from https://develop.svn.wordpress.org/trunk@40304


git-svn-id: http://core.svn.wordpress.org/trunk@40211 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Weston Ruter 2017-03-19 00:04:43 +00:00
parent 280bfe7933
commit e69b9b244c
3 changed files with 12 additions and 11 deletions

View File

@ -528,10 +528,11 @@
* *
* @since 4.1.0 * @since 4.1.0
* *
* @param {Boolean} active * @param {boolean} active - The active state to transiution to.
* @param {Object} args * @param {Object} [args] - Args.
* @param {Object} args.duration * @param {Object} [args.duration] - The duration for the slideUp/slideDown animation.
* @param {Object} args.completeCallback * @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 ) { onChangeActive: function( active, args ) {
var construct = this, var construct = this,
@ -564,24 +565,24 @@
} }
} }
if ( ! $.contains( document, headContainer ) ) { if ( ! $.contains( document, headContainer.get( 0 ) ) ) {
// jQuery.fn.slideUp is not hiding an element if it is not in the DOM // 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 ); headContainer.toggle( active );
if ( args.completeCallback ) { if ( args.completeCallback ) {
args.completeCallback(); args.completeCallback();
} }
} else if ( active ) { } else if ( active ) {
headContainer.stop( true, true ).slideDown( duration, args.completeCallback ); headContainer.slideDown( duration, args.completeCallback );
} else { } else {
if ( construct.expanded() ) { if ( construct.expanded() ) {
construct.collapse({ construct.collapse({
duration: duration, duration: duration,
completeCallback: function() { completeCallback: function() {
headContainer.stop( true, true ).slideUp( duration, args.completeCallback ); headContainer.slideUp( duration, args.completeCallback );
} }
}); });
} else { } else {
headContainer.stop( true, true ).slideUp( duration, args.completeCallback ); headContainer.slideUp( duration, args.completeCallback );
} }
} }
}, },

File diff suppressed because one or more lines are too long

View File

@ -4,7 +4,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '4.8-alpha-40303'; $wp_version = '4.8-alpha-40304';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.