Fix: Programmatic required error does not work as expected on the toggle control#74952
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 df5afe4. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/21371001426
|
|
Using ✅ I have tested it, and it's clearly solving this, but my question is: Why don't we get to the root of the problem with the I'm proposing an alternative here #74956 feel free to comment, I've recently started to dig in DataViews/DataForms so maybe I don't have full context. |
Fixes an issue reported by @oandregal where on toggle control the programmatic errors don't work as expected.
The cause was a timing bug where the Toggle field's validation error was not displayed after opening a previously collapsed card, even though the badge correctly showed the field count.
The solution was to change
useEffecttouseLayoutEffectinValidatedToggleControlso therequiredattribute is set on the input beforeControlWithError's effect readsvalidationMessageTesting
?path=/story/dataviews-dataform--validation&args=layout:card-collapsible