Skip to content

Conversation

@oandregal
Copy link
Member

@oandregal oandregal commented Sep 15, 2025

Part of #71500

What?

  • Add support for description in the radio control.
  • Add support for required and custom validation in radio control.

Why?

So that all controls support basic validation.

How?

Use the existing ValidatedRadioControl component.

Testing Instructions

In the storybook (npm run storybook:dev) verify that:

  • The description is present for radio in the story: "DataViews > Field Types > Text" (the "Help for text with radio" text):
Screenshot 2025-09-15 at 15 57 56
  • It can take required and custom validation in the "DataViews > DataForm > Validation" story:
Screen.Recording.2025-09-15.at.15.59.17.mov

@oandregal oandregal self-assigned this Sep 15, 2025
@oandregal oandregal added [Type] Enhancement A suggestion for improvement. [Feature] DataViews Work surrounding upgrading and evolving views in the site editor and beyond labels Sep 15, 2025
@oandregal oandregal marked this pull request as ready for review September 15, 2025 14:01
@github-actions
Copy link

github-actions bot commented Sep 15, 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: oandregal <[email protected]>
Co-authored-by: ellatrix <[email protected]>

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

@oandregal oandregal force-pushed the update/dataform-validated-radio branch from d15f0e3 to 4468771 Compare September 16, 2025 18:30
@github-actions
Copy link

Flaky tests detected in 4468771.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/17775435808
📝 Reported issues:

setCustomValidity( undefined );
},
[ data, field, setValue ]
);
Copy link
Member

Choose a reason for hiding this comment

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

I don't particularly love APIs that rely on the user of them to memoize props. 😅 I wonder if there's a way to avoid that, but that's a bigger question across all fields probably.

Copy link
Member

Choose a reason for hiding this comment

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

For example: why is field an object and each property not a prop?

Copy link
Member

Choose a reason for hiding this comment

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

Alternatively, if all properties of field are known, could we just list them here and construct the object within the callback? Or perhaps reconstruct a memoized field object beforehand to use everywhere? 🤔

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'll look into this separately to make sure the callback is not invalidated in every render.

@ellatrix
Copy link
Member

ellatrix commented Sep 17, 2025

Not introduced here, but I noticed the story for ValidatedRadioControl doesn't work? Or maybe I'm using it wrong.

image

@ellatrix
Copy link
Member

Actually, I'm having problems testing it. It seems I have the same issue with the DataForm validation section. required and custom are true by default, but I'm not seeing any red text from validation. Maybe I'm doing something wrong? I double checked my build by running npm install and rebuilding.

@ellatrix
Copy link
Member

Actually it works in Chrome, but not Safari for me.

@ellatrix
Copy link
Member

It looks like an issue with ValidatedRadioControl, so I won't block this PR for that

@oandregal
Copy link
Member Author

I talked this with Ella in private, and she uncovered an issue with the underlying validated controls and Safari. I've been able to reproduce it in ValidatedRadioControl and ValidatedCheckboxControl, for example). It works fine in Chrome and Firefox. cc @mirka for awareness.

Here's validation not working in Safari when interacting with the mouse:

Screen.Recording.2025-09-17.at.10.04.23.mov

Here's validation working in Safari when interacting with the keyboard:

Screen.Recording.2025-09-17.at.10.04.41.mov

@oandregal oandregal merged commit 86c423a into trunk Sep 17, 2025
78 checks passed
@oandregal oandregal deleted the update/dataform-validated-radio branch September 17, 2025 08:21
@github-actions github-actions bot added this to the Gutenberg 21.7 milestone Sep 17, 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.

3 participants