Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/dataviews/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@

- Revert the ability to hide the view config via `config` prop and export a `DataViews.Footer` component to support the "Minimal UI" story. [#71276](https://github.com/WordPress/gutenberg/pull/71276)

### Enhancements

- DataForm: add description support for the combined fields and show the description in the Card layout ([#71380](https://github.com/WordPress/gutenberg/pull/71380)).

### Bug Fixes

- DataViews: Fix incorrect documentation for `defaultLayouts` prop. [#71334](https://github.com/WordPress/gutenberg/pull/71334)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -671,6 +671,8 @@ const LayoutCardComponent = ( { withHeader }: { withHeader: boolean } ) => {
{
id: 'customerCard',
label: 'Customer',
description:
'Enter your contact details, plan type, and addresses to complete your customer information.',
children: [
{
id: 'customerContact',
Expand Down
5 changes: 5 additions & 0 deletions packages/dataviews/src/dataforms-layouts/card/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,11 @@ export default function FormCardField< Item >( {
// 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.

<div className="dataforms-layouts-card__field-description">
{ field.description }
</div>
) }
<DataFormLayout
data={ data }
form={ form }
Expand Down
7 changes: 7 additions & 0 deletions packages/dataviews/src/dataforms-layouts/card/style.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
.dataforms-layouts-card__field {
width: 100%;
}

.dataforms-layouts-card__field-description {
color: $gray-700;
display: block;
font-size: $font-size-medium;
margin-bottom: $grid-unit-20;
}
1 change: 1 addition & 0 deletions packages/dataviews/src/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@
@import "./dataform-controls/style.scss";
@import "./dataforms-layouts/panel/style.scss";
@import "./dataforms-layouts/regular/style.scss";
@import "./dataforms-layouts/card/style.scss";
1 change: 1 addition & 0 deletions packages/dataviews/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -738,6 +738,7 @@ export type SimpleFormField = {
export type CombinedFormField = {
id: string;
label?: string;
description?: string;
layout?: Layout;
children: Array< FormField | string >;
};
Expand Down
Loading