Layout: only show inherit toggle in default layout (hide on Row block variation)#39665
Conversation
| const showInheritToggle = !! ( | ||
| allowInheriting && | ||
| !! defaultThemeLayout && | ||
| ( ! layout?.type || layout?.type === 'default' || layout?.inherit ) |
There was a problem hiding this comment.
Note: I've added layout?.inherit to this conditional so that any blocks that are currently in the weird state of having a flex type but inheriting from the default layout can switch off inherit via the UI.
There was a problem hiding this comment.
Should we make the toggle disappear if they do toggle it off in this state or is that too confusing for the user?
There was a problem hiding this comment.
Thanks for taking a look @glendaviesnz — currently, toggling inherit also switches the type to default since the layout attribute is cleared out of anything but the inherit property (so the toggle would still be visible). Given how the toggle works, I'm hoping we don't actually have anyone in that weird circumstance of inherit being set to true and the type being set to something other than default.
I mostly added the layout?.inherit to be cautious just in case something was set manually to that state, but I'm not sure if it ever would have been possible to get into that state via the UI, so it's possibly an artificial example 🤔
|
Size Change: +47 B (0%) Total Size: 1.21 MB
ℹ️ View Unchanged
|
Right now, I think this is a safe assumption. |
youknowriad
left a comment
There was a problem hiding this comment.
This makes sense to me.
glendaviesnz
left a comment
There was a problem hiding this comment.
Worked as advertised for me
|
Thanks for the reviews, folks! 🙇 |
What?
Hide the "Inherit default layout" toggle if the current layout type is not of the default layout type. This allows us to hide the toggle in the Row variation of the Group block.
This is an opinionated change — the assumption here is that the default layout that we're inheriting from will always be implicitly of the "default" layout type. Is this a safe assumption to make?
Why?
As raised in reviews of #39650, the inherit toggle doesn't make much sense for a Row block, and possibly not for any other Flex-based layout. The toggle for the Row block also caused a problem that it'd unexpectedly switch the blog over to the Group variation again. Hiding the toggle altogether potentially resolves both problems.
How?
Update the conditional that determines whether or not to show the layout "Inherit default layout" control so that it can only appear on default / flow layouts.
Testing Instructions
To be really thorough, also check that you can switch off inherit on a block that does have inherit and "flex" so that these erroneous blocks don't wind up in a stuck state. E.g. using the following markup:
Screenshots or screencast
Note, the Orientation control is visible in the Row block in the below screenshots, but will be removed as of #39650.