plone / volto

React-based frontend for the Plone Content Management System
https://demo.plone.org/
MIT License
446 stars 606 forks source link

Helpers for building block with nested blocks #4525

Open JeffersonBledsoe opened 1 year ago

JeffersonBledsoe commented 1 year ago

Is your feature request related to a problem? Please describe. To implement the functionality of 'nested' blocks (such as the volto-blocks-grid or volto-accordion-block) currently, developers need to understand and re-implement the functionality of the Volto Form component. This includes things like showing the 'new block add button', initialising valid block data, rendering child blocks and handling block data changes. While there are a number of components in Volto to help with this functionality, the logic behind how to compose these components to create a functioning 'block with sub-blocks' is still fairly involved.

Describe the solution you'd like Components/ hooks/ HOCs that can be used by developers to more easily create custom blocks which render sub-blocks

Describe alternatives you've considered

Additional context An additional bonus to having Volto handle more of the composition of these components is it will be easier to make changes to development, data and UX in the future, as the implementation will be more consistent than having devs implement these things themselves.

yahya-cloud commented 1 year ago

Yes it'll be great to have helpers to make nested blocks, I encountered the same situation,

I was trying to make a volto block which renders other volto blocks, until now i am able to setup blockForm and was able to render a slate component inside it.

the problem I'm facing is that when i hit "enter button" instead of creation of new block inside child blockForm component it is rendered inside parent blockform component any help in this regard will be immensely appreciated.

here is the repository :- repo I've named that block as "BlockGroup" you can find it at src/components/Blocks/BlockGroup