Array fields show empty collapsible content even if there are no visible fields inside
Description
Array fields currently assume that any fields inside each item will be visible.
However, when using only slots nested inside array fields, or invisible fields, nothing is actually shown inside each item. In those cases, the field is mostly used just to add items to a list and reorder them.
In those scenarios, it would make sense to not make each item collapsible/expandable, since expanding shows no visible content and can be confusing.
Environment
- Puck version: 0.20.2
Steps to reproduce
-
Render the Puck editor with a component that uses slots inside an array field:
const config = { components: { Test: { fields: { columns: { type: "array", arrayFields: { items: { type: "slot" } }, defaultItemProps: { items: [] }, }, }, defaultProps: { columns: [] }, render: ({ columns }) => ( <div> {columns.map(({ items: Items }) => ( <Items /> ))} </div> ), }, }, }; export const Editor = () => { return <Puck data={{}} config={config} />; }; -
Run the application
-
Navigate to the editor
-
Drag and drop the component that uses the nested slots into the canvas
-
Select the component
-
Add items to the array field
-
Click on any of the items
What happens
Array items expand, even though no fields or content are shown inside.
What I expect to happen
If no visible fields are available in the array field items, then the items should not be collapsible/expandable.
Considerations
- The file that implements array fields is here.
- The line that renders the collapsible element is here.
Additional Media
hii @FedericoBonel 👋
If this Issue is still available, I would like to work on this.
Hey @kuntlme! Feel free to open a PR 🙏
Just a quick reminder:
- Slots are not visible by default
- Every field has a
visibleconfig parameter that can be set tofalseto hide it Looking forward to it, and thank you for taking this on
Thanks for the clarification, @FedericoBonel! Got it 👍 I’ll take care of that and open a PR once I’m done.
Awesome! Also, I almost forgot, in case you haven’t already, make sure to give this a quick skim so you’re familiar with how we typically handle contributions.