Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sidebar: Expand advanced panel if only item in settings tab #46024

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,18 @@ import {
default as InspectorControls,
InspectorAdvancedControls,
} from '../inspector-controls';
import InspectorControlsGroups from '../inspector-controls/groups';

const AdvancedControls = () => {
const fills = useSlotFills( InspectorAdvancedControls.slotName );
const hasFills = Boolean( fills && fills.length );

// Check fills in settings tab to determine initial open state for panel.
const tabsEnabled = window?.__experimentalEnableBlockInspectorTabs;
const { default: defaultGroup } = InspectorControlsGroups;
const settingFills = useSlotFills( defaultGroup.Slot.__unstableName ) || [];
const open = !! tabsEnabled && ! settingFills.length;

if ( ! hasFills ) {
return null;
}
Expand All @@ -27,7 +34,7 @@ const AdvancedControls = () => {
<PanelBody
className="block-editor-block-inspector__advanced"
title={ __( 'Advanced' ) }
initialOpen={ false }
initialOpen={ open }
>
<InspectorControls.Slot __experimentalGroup="advanced" />
</PanelBody>
Expand Down