Skip to content

DataForm: Allow React elements in form field descriptions - #84002

Closed
dmallory42 wants to merge 4 commits into
WordPress:trunkfrom
dmallory42:update/dataform-form-field-description-element
Closed

dmallory42 wants to merge 4 commits into
WordPress:trunkfrom
dmallory42:update/dataform-form-field-description-element

Conversation

@dmallory42

@dmallory42 dmallory42 commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

What?

Lets a form field's description in DataForm be a React element as well as a string, so a card's description can include a link.

Why?

In the card layout, a card that groups fields shows its form field's description at the top of the card. That property only accepts a string, so the text can't contain a link such as "Learn more" or "View the documentation".

A field's own description already accepts a React element (Field.description in types/field-api.ts), so links under individual fields work today.

How?

  • Change FormField.description and NormalizedFormField.description from string to string | ReactElement, matching Field.description. The card layout is the only layout that renders a form field's description, and it already renders it as a React child, so only the types change. normalizeForm passes the value through unchanged.
  • Update the description entry in the README's Form Field API section, and the changelog.
  • Add a unit test for a card whose description contains a link, and add a "Learn more" link to the File details card in the card layout story.

Testing Instructions

  1. Run npm run storybook:dev and open Design System > DataViews > DataForm > Layout Card.
  2. Check that the File details card's description reads "Size, dimensions, and type of the uploaded file." followed by a "Learn more" link to wordpress.org/documentation.
  3. Check that the Customer card's plain-text description still shows as before.

Testing Instructions for Keyboard

In the Layout Card story, press Tab to move through the File details card. The "Learn more" link should receive focus, and pressing Enter should follow it.

Screenshots or screencast

card-description-link

Use of AI Tools

I wrote this PR with Claude Code (Claude Opus 5.5), which made the code changes. I wrote the PR description. I've reviewed the changes and take responsibility for them.

dmallory42 and others added 2 commits October 1, 2026 21:06
A card's description comes from its form field's `description`, which
only accepted a string, so it couldn't include a link. A field's own
`description` already accepts a React element. Widen the form field
type to match, and document it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added the [Package] DataViews /packages/dataviews label Oct 1, 2026
@github-actions

github-actions Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

🤖 PR meta 🤖

🎉 Props

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: dmallory42 <dmallory42@git.wordpress.org>

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

Updated as activity occurs, without notifying anyone named here. Add the props-bot label to refresh.

🏷️ Labels

This pull request needs exactly one label indicating its type, and has 0.

  • Required: any label starting with [Type].
  • Found: none.

Read more about Type labels in Gutenberg. If you cannot add labels yourself, a reviewer can do it for you.

dmallory42 and others added 2 commits October 1, 2026 21:32
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dmallory42
dmallory42 marked this pull request as ready for review October 1, 2026 20:38
@dmallory42

Copy link
Copy Markdown
Contributor Author

This idea was already proposed and rejected here. Closing this PR.

@dmallory42 dmallory42 closed this Oct 1, 2026
@dmallory42
dmallory42 deleted the update/dataform-form-field-description-element branch October 1, 2026 20:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Package] DataViews /packages/dataviews

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant