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

Improvements to "inherit default layout" toggle #41893

Merged
merged 3 commits into from
Jun 27, 2022
Merged
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
29 changes: 20 additions & 9 deletions packages/block-editor/src/hooks/layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,15 +130,26 @@ function LayoutPanel( { setAttributes, attributes, name: blockName } ) {
<InspectorControls>
<PanelBody title={ __( 'Layout' ) }>
{ showInheritToggle && (
<ToggleControl
label={ __( 'Inherit default layout' ) }
checked={ !! inherit }
onChange={ () =>
setAttributes( {
layout: { inherit: ! inherit },
} )
}
/>
<>
<ToggleControl
label={ __( 'Blocks use full width' ) }
checked={ ! inherit }
onChange={ () =>
setAttributes( {
layout: { inherit: ! inherit },
} )
}
/>
<p className="block-editor-hooks__layout-controls-helptext">
{ !! inherit
? __(
'Nested blocks use default content width with options for full and wide widths.'
Copy link
Contributor

Choose a reason for hiding this comment

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

Just double-checking: it isn't possible for blocks-based themes to switch off full and wide alignments altogether is it? I tested this PR in a classic theme without the alignments, and it results in showInheritToggle being false, so I assume that if a user can see this control then their theme supports both full / wide options.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good question! Block themes can switch off wide/full alignments, but only by removing the layout section in their theme.json settings altogether, which means they're not able to set content size/wide size either. I somehow don't see that being a popular choice, but if it is done, then the toggle doesn't show:

Screen Shot 2022-06-27 at 11 13 26 am

Copy link
Contributor

Choose a reason for hiding this comment

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

Perfect 👍

I somehow don't see that being a popular choice

Me either, but good to know what happens just in case someone tries to get rid of it altogether!

)
: __(
'Nested blocks will fill the width of this container'
tellthemachines marked this conversation as resolved.
Show resolved Hide resolved
) }
</p>
</>
) }

{ ! inherit && allowSwitching && (
Expand Down