Description
Description
I will use this post to document all issues that I find related to styles for ButtonBlockAppender and even the normal BlockListAppender.
I suspect that several styles related to the ButtonBlockAppender component are erroneously selecting group block. This is a problem because the component is not exclusive to the group block.
In packages/block-editor/src/components/button-block-appender/content.scss
at line 37 and 38:
.block-editor-block-list__block:not(.is-selected) > .is-layout-constrained.wp-block-group__inner-container > &,
.block-editor-block-list__block:not(.is-selected) > .is-layout-flow.wp-block-group__inner-container > & {
The incorrect selector is .wp-block-group__inner-container
, when it should be a block-agnostic selector, namely the .block-editor-block-list__layout
class that is applied to the inner containers automatically. Because of this, the styles are not applied to ButtonBlockAppender when a custom block opts-in to use it along with the common block JSX structure:
const blockProps = useBlockProps();
const innerBlocksProps = useInnerBlocksProps(
{ className: 'wp-block-my-block__inner-container' },
{
renderAppender: InnerBlocks.ButtonBlockAppender,
}
);
return (
<TagName { ...blockProps }>
<div { ...innerBlocksProps } />
</TagName>
)
In packages/block-library/src/group/editor.scss
are also several styles that improve the appearance of ButtonBlockAppender in different layout configurations for the group block. These styles would be just as useful for custom blocks that opt-in for the layout support controls, specifically when allowSwitching
is set to true which enables the same layout capabilities as the group block. I believe that these styles should be moved from the group block, in to the button-block-appender's css but with corrected selectors.
Step-by-step reproduction instructions
Create a block with the common pattern as shown above. Set allowSwitching to true in supports>layout in block.json.
Screenshots, screen recording, code snippet
No response
Environment info
Gutenberg 20.8.0
Please confirm that you have searched existing issues in the repo.
- Yes
Please confirm that you have tested with all plugins deactivated except Gutenberg.
- Yes
Please confirm which theme type you used for testing.
- Block
- Classic
- Hybrid (e.g. classic with theme.json)
- Not sure