DataForm: Allow React elements in form field descriptions - #84002
Closed
dmallory42 wants to merge 4 commits into
Closed
dmallory42 wants to merge 4 commits into
dmallory42 wants to merge 4 commits into
Conversation
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>
🤖 PR meta 🤖🎉 PropsIf 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. Updated as activity occurs, without notifying anyone named here. Add the 🏷️ LabelsThis pull request needs exactly one label indicating its type, and has 0.
Read more about Type labels in Gutenberg. If you cannot add labels yourself, a reviewer can do it for you. |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
dmallory42
marked this pull request as ready for review
October 1, 2026 20:38
dmallory42
requested review from
gigitux,
ntsekouras and
oandregal
as code owners
October 1, 2026 20:38
Contributor
Author
|
This idea was already proposed and rejected here. Closing this PR. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What?
Lets a form field's
descriptionin 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
descriptionat 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
descriptionalready accepts a React element (Field.descriptionintypes/field-api.ts), so links under individual fields work today.How?
FormField.descriptionandNormalizedFormField.descriptionfromstringtostring | ReactElement, matchingField.description. The card layout is the only layout that renders a form field'sdescription, and it already renders it as a React child, so only the types change.normalizeFormpasses the value through unchanged.descriptionentry in the README's Form Field API section, and the changelog.Testing Instructions
npm run storybook:devand open Design System > DataViews > DataForm > Layout Card.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
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.