CARVIEW |
Navigation Menu
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
DataForm toggleGroup control: support validation #71666
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
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. |
); | ||
return ( | ||
<ToggleGroupControl | ||
<ValidatedToggleGroupControl |
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.
@mirka Unless I'm doing something wrong, it looks like the required validation is not working for the ValidatedToggleGroupControl. It should be triggered when:
- the control starts with no value selected
- it gets focus and then loses it
The same happens in the component story.
Do you have any thoughts here (feel free to push to this PR if that helps)?
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.
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.
In testing, it looks like if I tab to the control and tab away without selecting anything, it appears to correctly fire the validation. The validation doesn't appear to fire on the initial load of the story. That sounds fine to me, as the label indicates it's a required field, but just thought I'd double check that's what you were expecting, Andrรฉ?
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.
The validation doesn't appear to fire on the initial load of the story. That sounds fine to me, as the label indicates it's a required field, but just thought I'd double check that's what you were expecting, Andrรฉ?
Yeah, that's how validation works at the component level: it runs on blur the 1st time, then upon every user change.
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.
); | ||
return ( | ||
<ToggleGroupControl | ||
<ValidatedToggleGroupControl |
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.
In testing, it looks like if I tab to the control and tab away without selecting anything, it appears to correctly fire the validation. The validation doesn't appear to fire on the initial load of the story. That sounds fine to me, as the label indicates it's a required field, but just thought I'd double check that's what you were expecting, Andrรฉ?
b3eb849
to
3630af8
Compare
Flaky tests detected in e3ec46f. ๐ Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/17757849558
|
Part of #71500
What?
Add support for
required
andcustom
validation in toggle group control.Why?
So that all controls support basic validation.
How?
Use the existing
ValidatedToggleGroupControl
component.Testing Instructions
In the storybook (
npm run storybook:dev
) verify that it can takerequired
andcustom
validation in the "DataViews > DataForm > Validation" story:Screen.Recording.2025-09-15.at.16.51.47.mov