-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Layout: show inherit toggle in the absence of settings.layout object
#59580
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -125,14 +125,13 @@ export function useLayoutStyles( blockAttributes = {}, blockName, selector ) { | |
| const fullLayoutType = getLayoutType( usedLayout?.type || 'default' ); | ||
| const [ blockGapSupport ] = useSettings( 'spacing.blockGap' ); | ||
| const hasBlockGapSupport = blockGapSupport !== null; | ||
| const css = fullLayoutType?.getLayoutStyle?.( { | ||
| return fullLayoutType?.getLayoutStyle?.( { | ||
| blockName, | ||
| selector, | ||
| layout, | ||
| style, | ||
| hasBlockGapSupport, | ||
| } ); | ||
| return css; | ||
| } | ||
|
|
||
| function LayoutPanelPure( { | ||
|
|
@@ -144,8 +143,6 @@ function LayoutPanelPure( { | |
| const settings = useBlockSettings( blockName ); | ||
| // Block settings come from theme.json under settings.[blockName]. | ||
| const { layout: layoutSettings } = settings; | ||
| // Layout comes from block attributes. | ||
| const [ defaultThemeLayout ] = useSettings( 'layout' ); | ||
| const { themeSupportsLayout } = useSelect( ( select ) => { | ||
| const { getSettings } = select( blockEditorStore ); | ||
| return { | ||
|
|
@@ -180,11 +177,9 @@ function LayoutPanelPure( { | |
| } | ||
|
|
||
| // Only show the inherit toggle if it's supported, | ||
| // a default theme layout is set (e.g. one that provides `contentSize` and/or `wideSize` values), | ||
| // and either the default / flow or the constrained layout type is in use, as the toggle switches from one to the other. | ||
| const showInheritToggle = !! ( | ||
| allowInheriting && | ||
| !! defaultThemeLayout && | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So I don't really know if this is safe. Things appear to work as expected. The scenario is that:
A value of Not sure 🤔
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good question! I haven't taken this PR for a spin, but does this affect classic themes at all? And is it a problem if when you toggle the inherit toggle, if it doesn't immediately apply any rules? I.e. if folks go to set child blocks to "wide" versus content alignment they mightn't see any difference until a value is entered in for the constrained controls 🤔 These are just drive-by comments, though, thanks for working on the fix! If it's still open in a couple of days, happy to take it for a spin and give it a proper review 🙂
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Good question. I smoke tested a couple and couldn't see any difference between this PR and trunk, but I didn't really go in depth. I'm just wondering if the approach is any good right now 🤷🏻
I'm not sure - I can't see any issue, but I'm a bit layout blind. Also, the fact that, on trunk, If we tighten up that test, so that we need Whatever folks think is the best way forward...
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Given that this whole UI is going to change once #53455 (or something similar) is ready, it's not too important to make this a perfect fix.
I think as long as the controls to set custom content/wide withs are shown, it's not super awkward 😅 because it exposes those controls, which once set will produce the visible effect. We could perhaps refine the check to make sure that either the theme sets a |
||
| ( ! layout?.type || | ||
| layout?.type === 'default' || | ||
| layout?.type === 'constrained' || | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ES lint was bugging me