Customize: Fix `focus()` to collapse child panels and show parent panel.

When a child panel is open, `wp.customize.panel('parent_panel').focus()` (e.g. `'parent_parent'` might be `'nav_menus'`) collapses the child panel(s) to show the parent panel. 

Follow-up to [30102], [31920], [38648].

Props celloexpressions, costdev, dlh, hareesh-pillai, hellofromTonya, westonruter, wpweaver. 
Fixes #34436.
Built from https://develop.svn.wordpress.org/trunk@52003


git-svn-id: http://core.svn.wordpress.org/trunk@51592 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
hellofromTonya 2021-11-03 15:05:58 +00:00
parent e2315352e9
commit 6a10d18458
3 changed files with 15 additions and 3 deletions

View File

@ -695,10 +695,22 @@
* @param {Function} [params.completeCallback]
*/
focus = function ( params ) {
var construct, completeCallback, focus, focusElement;
var construct, completeCallback, focus, focusElement, sections;
construct = this;
params = params || {};
focus = function () {
// If a child section is currently expanded, collapse it.
if ( construct.extended( api.Panel ) ) {
sections = construct.sections();
if ( 1 < sections.length ) {
sections.forEach( function ( section ) {
if ( section.expanded() ) {
section.collapse();
}
} );
}
}
var focusContainer;
if ( ( construct.extended( api.Panel ) || construct.extended( api.Section ) ) && construct.expanded && construct.expanded() ) {
focusContainer = construct.contentContainer;

File diff suppressed because one or more lines are too long

View File

@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '5.9-alpha-52002';
$wp_version = '5.9-alpha-52003';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.