-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Default block, but only within a parent/outer block #7573
Comments
Since #7732, the block inserter is no longer shown if the default block is not one of the blocks allowed in an InnerBlocks area. However, this makes the inner blocks area somewhat unusable unless it defines its own UI for adding child blocks, by modifying the template or some other method. As an example, I have a carousel block which can accept a couple different types of blocks as inner blocks content, but not the default paragraph block. Up till now I've been using the default block appender as the mechanism for inserting new content slides (with some CSS hackery to make the block appender appear as a new slide, and to prevent inserting and any blocks but the blocks I wanted to allow...) The block appender provides a really consistent and user-friendly interface for adding content to nested blocks. I think it would be really nice to be able to specify a default block for inner blocks areas that's different from the root default block, like this: <InnerBlocks
allowedBlocks={ [
'custom/responsive-image',
'custom/image-with-card',
] }
defaultBlock={ 'custom/responsive-image' }
/> which, along with some context-aware modifications to the logic in |
It looks like this functionality can be added via a custom appender added to |
When I press Tab after the last element in my inner block, Gutenberg helpfully creates a new paragraph for me. Unfortunately it's not one of the
allowedBlocks
for the parent and I would prefer that the default block is the one I choose. Is this possible?My research showed that I could use
setDefaultBlockName()
and I could possible hack it to respect the context (based on focus), but I hope there is a better way.The text was updated successfully, but these errors were encountered: