-
Notifications
You must be signed in to change notification settings - Fork 4.6k
DataForm: Add summary field support for composed fields #71614
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
DataForm: Add summary field support for composed fields #71614
Conversation
|
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 If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
Flaky tests detected in 0552132. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/17761854764
|
| id: 'discussion', | ||
| label: 'Discussion', | ||
| children: [ 'comment_status', 'ping_status' ], | ||
| summary: 'discussion', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm thinking that, sometimes, instead of using a single field as summary, we may want to display a couple of fields instead. For example, an airplane form. The summary may be [ 'origin_destination', 'status' ], and they'd be rendered in a new line each. Something along these lines:
FLIGHT DETAILS (label)
From SCQ to OPO (1st field render)
On Time (2nd field render)but when clicking on the panel it opens a modal with a lot more details (flight time, connections if any, etc.).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @oandregal, I added the option for multiple summary fields, it can be tested at http://localhost:50240/?path=/story/dataviews-dataform--multiple-summary-fields.

packages/dataviews/src/components/dataform/stories/index.story.tsx
Outdated
Show resolved
Hide resolved
| render: VisibilityComponent, | ||
| }; | ||
|
|
||
| export const MultipleSummaryFields = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we integrate this in the existing LayoutPanel story?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(It doesn't need to be everything, as long as there's one or two examples for each it's fine (a single summary field + a list of summary fields).
| item={ data } | ||
| field={ fieldDefinition } | ||
| /> | ||
| { summaryFields.length > 1 ? ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This button component could be extracted as an utility to both Modal and Panel. SummaryButton, perhaps?
389653a to
a5d386d
Compare
|
Hi @oandregal thank you for the reviews, all your feedback was applied. |
|
@jorgefilipecosta this needs a |
0dc77d7 to
621cf63
Compare
…e composed field.
….tsx Co-authored-by: André <[email protected]>
Co-authored-by: André <[email protected]>
621cf63 to
0552132
Compare
This PR adds support for custom summary rendering in composed DataForm fields through an optional
summaryproperty. Previously, composed fields would always display the first child field's value as the summary. Now, developers can specify which field's render method should be used for the summary display.Problem
When using composed fields (fields with children), the panel layout would always use the first simple child field to display the summary value. This limitation prevented meaningful summaries for complex composed fields where a custom rendering logic would be more appropriate.
For example, a "Discussion" field containing both comment status and ping status would only show the comment status, missing the complete picture.
Solution
Type Changes
CombinedFormFieldtype with optionalsummary?: stringpropertyImplementation
dataforms-layouts/panel/index.tsxsummaryproperty, the system looks for that field definition instead of defaulting to the first childUsage Example
Benefits
Testing
Go to http://localhost:50240/?path=/story/dataviews-dataform--layout-panel and verify the Discussion field works as expected.