Skip to content
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

feat: expand object + DZ fields via settings parameter >open< #4153

Conversation

ma-schmidt-de
Copy link
Contributor

Changes

The new attribute open of interface CmsModelFieldSettings controls whether the accordion renderer of objects and dynamic zones are expanded by default.
BREAKING CHANGE: none
Closes #4109

Screenshot 2024-06-04 at 14 19 45
Screenshot 2024-06-04 at 14 20 41

How Has This Been Tested?

Manually.

Documentation

I'm planning to add a "How to" section below this on in webiny.com/docs:
https://www.webiny.com/docs/headless-cms/extending/content-models-via-code#how-to-set-a-default-value-of-a-field

Copy link
Collaborator

@Pavel910 Pavel910 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a nice PR @ma-schmidt-de, but let's make it even better. The next branch now has this new feature called "renderer settings". Check out the draft changelog: https://docs-webiny-com-git-release-5400-webiny.vercel.app/docs/release-notes/5.40.0/changelog#field-renderer-settings

This feature that you've implemented would make much more sense as a renderer settings, not a field setting in general. If you think about it, what does open mean on a boolean field? So let's move this flag to renderer settings for dynamicZone and object field renderers. That way each renderer can have its own very specific settings, and the general field definition is not cluttered with unrelated properties.

Here's a reference to how you would use these settings in a renderer: https://github.com/webiny/webiny-js/blob/next/packages/app-headless-cms/src/admin/plugins/fieldRenderers/ref/advanced/components/ReferencesDialog.tsx#L81

And here's how you define new renderer settings, on a renderer level:
https://github.com/webiny/webiny-js/blob/next/packages/app-headless-cms/src/admin/plugins/fieldRenderers/ref/advanced/detailedReferencesRenderer.tsx#L40-L42

The settings will be stored into the renderer: { name: "...", settings: { ... } }.

@ma-schmidt-de
Copy link
Contributor Author

Sounds great, @Pavel910
I'll look into this and refactor my PR accordingly. 👍

@ma-schmidt-de
Copy link
Contributor Author

Let me actually open a new PR. I got mixed up a bit with branches in my fork. 🙂

@ma-schmidt-de
Copy link
Contributor Author

new PR: #4155

@ma-schmidt-de ma-schmidt-de deleted the feat/add-open-config-to-dz-and-object branch June 11, 2024 19:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

HCMS: Configure Dynamic Zone and Object field to be expanded by default
2 participants