Skip to content

Conversation

@dinhtungdu
Copy link
Member

What?

This PR adds description support for the combined fields and shows that description in the Card layout

Why?

For the combined field, we might also want to inform users of the purpose of the section. This is why we added the new description property here. In this PR, we are only showing that description for the Card layout because it should be handled at the layout level, as each layout has different needs and positions to display the description.

How?

  • Added description?: string property to CombinedFormField type
  • Updated card layout component to render descriptions inside CardBody before fields (combined fields only)
  • Simple fields continue using the existing description handling from field definitions

Testing Instructions

  1. Open DataViews DataForm storybook
  2. Navigate to "LayoutCard" story
  3. Verify combined fields display descriptions below the card header and above the fields

Screenshots or screencast

Before After
image image

@dinhtungdu dinhtungdu requested a review from oandregal as a code owner August 28, 2025 03:55
@github-actions
Copy link

github-actions bot commented Aug 28, 2025

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: dinhtungdu <dinhtungdu@git.wordpress.org>
Co-authored-by: oandregal <oandregal@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

// If it doesn't have a header, keep it open.
// Otherwise, the card will not be visible.
<CardBody className="dataforms-layouts-card__field-control">
{ field.description && (
Copy link
Member

Choose a reason for hiding this comment

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

This works for combined form fields (form fields with children), which is the main use case.

What about form fields that don't have children? In the LayoutCard story, there's an example with a single-form-field card, the payments card. Adding a label or description to that form field is ignored because it doesn't have children. It uses the label and description coming from the field definition, but note the description is attached to the regular control:

with header no header
Screenshot 2025-08-28 at 10 04 10 Screenshot 2025-08-28 at 10 04 46

It's perhaps fine to address only combined form fields in this PR. We can revisit single form fields in a follow-up.

Copy link
Member Author

Choose a reason for hiding this comment

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

I mentioned this in the PR description. Single fields using the Card layout are still rendered using the Regular layout. The field description is already handled by its Edit component, so I don't think the Card layout for a single field should show the description.

@oandregal It's not a big lift to update the single field case, but should we? The field can have two descriptions; could that be an issue?

Copy link
Member

Choose a reason for hiding this comment

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

It's fine as it is. My thinking is that "simple fields" may want to have a label and description, like combined field have. But that's a separate discussion we can address when/if that's raised.

@oandregal
Copy link
Member

oandregal commented Aug 28, 2025

@dinhtungdu this PR needs a changelog entry (see CI error). Follow the format that exists in packages/dataviews/CHANGELOG.md in a "Unreleased > Enhancement" section.

@oandregal oandregal added [Type] Enhancement A suggestion for improvement. [Feature] DataViews Work surrounding upgrading and evolving views in the site editor and beyond labels Aug 28, 2025
@dinhtungdu dinhtungdu requested a review from nerrad as a code owner August 28, 2025 10:37

## Unreleased

### Enhancements
Copy link
Member

Choose a reason for hiding this comment

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

This should be in packages/DATAVIEWS/changelog, not in core-data :) Also, it looks like your editor adds some formatting to other areas of the changelog.

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh my bad, I fixed it in the latest commit. 😅

@dinhtungdu dinhtungdu force-pushed the feat/card-layout-description branch from 703a7be to 35f453a Compare August 28, 2025 13:56
@dinhtungdu
Copy link
Member Author

@oandregal Can you help me merge this PR? I don't have permission to do it. Btw, the failed E2E test seems irrelevant.

@oandregal
Copy link
Member

Can you help me merge this PR? I don't have permission to do it. Btw, the failed E2E test seems irrelevant.

Sure, happy to.

I'm seeing some weird things that I don't know how to fix: the checks for node.js and PHP are expected/waiting for hours now. I asked in WordPress slack core-editor for advice. In lieu of that, my recommendation would be to rebase this PR from trunk.

@oandregal
Copy link
Member

In lieu of that, my recommendation would be to rebase this PR from trunk.

It turns out this would solve the problem :) There were some actions changes a few days ago and this PR is older than that.

@dinhtungdu dinhtungdu force-pushed the feat/card-layout-description branch from 35f453a to 40c6d9e Compare September 2, 2025 11:01
@oandregal oandregal merged commit 9458bcd into WordPress:trunk Sep 2, 2025
68 checks passed
@github-actions github-actions bot added this to the Gutenberg 21.6 milestone Sep 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Feature] DataViews Work surrounding upgrading and evolving views in the site editor and beyond [Type] Enhancement A suggestion for improvement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants