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

Add block inspector virtual bubbling option #24991

Merged
merged 2 commits into from
Sep 2, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
22 changes: 18 additions & 4 deletions packages/block-editor/src/components/block-inspector/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,17 @@ const BlockInspector = ( {
selectedBlockClientId,
selectedBlockName,
showNoBlockSelectedMessage = true,
bubblesVirtually = true,
} ) => {
if ( count > 1 ) {
return (
<div className="block-editor-block-inspector">
<MultiSelectionInspector />
<InspectorControls.Slot bubblesVirtually />
{ bubblesVirtually ? (
<InspectorControls.Slot bubblesVirtually />
) : (
<InspectorControls.Slot />
) }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could these be written without the ternary?

Suggested change
{ bubblesVirtually ? (
<InspectorControls.Slot bubblesVirtually />
) : (
<InspectorControls.Slot />
) }
<InspectorControls.Slot bubblesVirtually={ bubblesVirtually } />

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, yes, of course!

</div>
);
}
Expand Down Expand Up @@ -79,18 +84,23 @@ const BlockInspector = ( {
</PanelBody>
</div>
) }
<InspectorControls.Slot bubblesVirtually />
{ bubblesVirtually ? (
<InspectorControls.Slot bubblesVirtually />
) : (
<InspectorControls.Slot />
) }
<div>
<AdvancedControls
slotName={ InspectorAdvancedControls.slotName }
bubblesVirtually={ bubblesVirtually }
/>
</div>
<SkipToSelectedBlock key="back" />
</div>
);
};

const AdvancedControls = ( { slotName } ) => {
const AdvancedControls = ( { slotName, bubblesVirtually } ) => {
const slot = useSlot( slotName );
const hasFills = Boolean( slot.fills && slot.fills.length );

Expand All @@ -104,7 +114,11 @@ const AdvancedControls = ( { slotName } ) => {
title={ __( 'Advanced' ) }
initialOpen={ false }
>
<InspectorAdvancedControls.Slot bubblesVirtually />
{ bubblesVirtually ? (
<InspectorAdvancedControls.Slot bubblesVirtually />
) : (
<InspectorAdvancedControls.Slot />
) }
</PanelBody>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,9 @@ export default function BlockEditorArea( {
label="Block inspector"
/>
) }
renderContent={ () => <BlockInspector /> }
renderContent={ () => (
<BlockInspector bubblesVirtually={ false } />
) }
/>
</CardHeader>
<CardBody>
Expand Down