Skip to content

Conversation

@jorgefilipecosta
Copy link
Member

@jorgefilipecosta jorgefilipecosta commented Jan 12, 2026

Summary

Part of: #72321

Adds validation support to the card form layout, similar to #73700 (panel layout validation).

  • Displays a badge in the card header showing "X field(s) need attention" when there are invalid fields
  • For collapsible cards: badge appears after collapsing the card
  • For non-collapsible cards: badge appears after blurring from any field inside
  • Includes a non-collapsible card example in the Validation story

Screenshot

Screenshot 2026-01-12 at 14 39 48 Screenshot 2026-01-12 at 14 39 33

Test plan

  1. Go to Storybook > DataViews > DataForm > Validation
  2. Select layout: "card"
  3. For collapsible cards: expand, clear a required field, collapse - badge should appear
  4. For non-collapsible cards ("Text Fields"): clear a required field and blur - badge should appear
  5. Verify singular/plural: "1 field needs attention" vs "2 fields need attention"

@github-actions
Copy link

github-actions bot commented Jan 12, 2026

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: jorgefilipecosta <[email protected]>
Co-authored-by: ntsekouras <[email protected]>
Co-authored-by: oandregal <[email protected]>
Co-authored-by: jameskoster <[email protected]>
Co-authored-by: aduth <[email protected]>
Co-authored-by: poligilad-auto <[email protected]>

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

@github-actions github-actions bot added the [Package] DataViews /packages/dataviews label Jan 12, 2026
@jorgefilipecosta jorgefilipecosta added the [Type] Enhancement A suggestion for improvement. label Jan 12, 2026
@github-actions
Copy link

github-actions bot commented Jan 12, 2026

Flaky tests detected in 4c2556c.
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/21350774613
📝 Reported issues:

@jameskoster
Copy link
Contributor

Looks good. What do you think @poligilad-auto? Do we need the badge on non-collapsible cards too? I can go either way on that.

Separately I'm curious what it would it take for us to be able to use the new Badge from @wordpress/ui here? cc @ciampo @aduth. I'm assuming it won't be possible until ThemeProvider is adopted at a certain layer?

@aduth
Copy link
Member

aduth commented Jan 13, 2026

Separately I'm curious what it would it take for us to be able to use the new Badge from @wordpress/ui here? cc @ciampo @aduth. I'm assuming it won't be possible until ThemeProvider is adopted at a certain layer?

DataViews already embeds the base design token variables (some concern about this approach, but not a blocker for consideration here). There's still likely a need to incorporate ThemeProvider somewhere to effect theming like user color preference, but from DataViews perspective it should be possible to use these components now. DataViews already uses Stack, for example.

I too would be very interested in using @wordpress/ui Badge here and helping address whatever supports need to be in place to make that happen. Elsewhere, I'd proposed getting rid of the @wordpress/components Badge implementation altogether.

@jorgefilipecosta
Copy link
Member Author

I will try to use @wordpress/ui here, here and share if there is any issue ☺️

@jorgefilipecosta jorgefilipecosta force-pushed the add/details-layout-panel-validation branch from 1916f4f to ea656f5 Compare January 13, 2026 20:20
@jorgefilipecosta
Copy link
Member Author

The change to use @wordpress/ui is done, it was straightforward:
Screenshot 2026-01-13 at 20 31 59

Can be tested at http://localhost:50240/?path=/story/dataviews-dataform--validation&args=layout:card.

@poligilad-auto
Copy link

poligilad-auto commented Jan 14, 2026

Looks good. What do you think @poligilad-auto? Do we need the badge on non-collapsible cards too? I can go either way on that.

If the relevant error is already visible in the field, I don't think the badge is required on non-collapsible cards.

@jorgefilipecosta jorgefilipecosta force-pushed the add/details-layout-panel-validation branch 2 times, most recently from faf5143 to 5c59f1e Compare January 15, 2026 09:40
@jorgefilipecosta
Copy link
Member Author

Looks good. What do you think @poligilad-auto? Do we need the badge on non-collapsible cards too? I can go either way on that.

If the relevant error is already visible in the field, I don't think the badge is required on non-collapsible cards.

Hi @poligilad-auto, @jameskoster thank you for reviewing this PR. I removed. the badge from the non colapsible panel.

@oandregal
Copy link
Member

Note this interaction:

  • fill data that triggers error in control: error is displayed in control
  • collapse the card: badge in card is displayed
  • open the card to see the actions: the control no longer has the error

Can we perhaps leverage this technique to trigger the error in those scenarios?

Screen.Recording.2026-01-16.at.14.18.23.mov

@oandregal
Copy link
Member

oandregal commented Jan 16, 2026

Note this interaction: the bagde is visible immediately after having collapsed the card first. It results on sometimes the badge appearing immediately (if you had collapsed the card before) and sometimes appearing after collapsing. I suppose it's not a big deal, but I wonder: in collapsible cards, can we just display the badge every time there's an error? cc @jameskoster @poligilad-auto We could get rid of the touch-related code.

Screen.Recording.2026-01-16.at.14.22.44.mov

@jameskoster
Copy link
Contributor

in collapsible cards, can we just display the badge every time there's an error?

You mean even if it's open? I don't love the inconsistency with non-collapsible cards, but maybe it's okay in the short-term.

What I find more concerning is this state:

Screenshot 2026-01-16 at 17 33 45

The badge informs the user there's an issue, but none of the fields are marked. I think this is due to a separate issue and is being addressed elsewhere, but wanted to highlight just in case.

@jorgefilipecosta jorgefilipecosta force-pushed the add/details-layout-panel-validation branch from 9aa6561 to 91f808f Compare January 16, 2026 19:37
@oandregal
Copy link
Member

You mean even if it's open? I don't love the inconsistency with non-collapsible cards, but maybe it's okay in the short-term.

We already display the badge when the card is open, but only if the card has been collapsed before.

For example, this doesn't display the badge immediately:

Screen.Recording.2026-01-19.at.12.55.52.mov

But this does:

Screen.Recording.2026-01-19.at.12.56.11.mov

I was thinking that we should display the badge always, regardless of whether the card had been collapsed before or not.

@jorgefilipecosta jorgefilipecosta force-pushed the add/details-layout-panel-validation branch 2 times, most recently from eefdbea to 35b24db Compare January 19, 2026 20:09
@jorgefilipecosta jorgefilipecosta force-pushed the add/details-layout-panel-validation branch from 758bd8e to e392a73 Compare January 23, 2026 22:39
Copy link
Contributor

@ntsekouras ntsekouras left a comment

Choose a reason for hiding this comment

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

I think this is good to land, thanks! Not sure if you want to wait for @oandregal to have another pass about the interactions, but I tested all the previous ones mentioned and seem to work nicely.

@jorgefilipecosta
Copy link
Member Author

I think this is good to land, thanks! Not sure if you want to wait for @oandregal to have another pass about the interactions, but I tested all the previous ones mentioned and seem to work nicely.

Thank you for the review @ntsekouras, and @oandregal, I will go for the merge, but I'm happy to iterate if we find anything needing improvements. I will also look at some issues in the input controls programmatic validation triggering separately.

@jorgefilipecosta jorgefilipecosta merged commit bb74003 into trunk Jan 26, 2026
40 checks passed
@jorgefilipecosta jorgefilipecosta deleted the add/details-layout-panel-validation branch January 26, 2026 10:27
@github-actions github-actions bot added this to the Gutenberg 22.5 milestone Jan 26, 2026
@oandregal
Copy link
Member

Great work here, Jorge. The idea of reporting validity in the controls upon opening the card can be implemented in the panel as well. I've updated the tasks at #72321

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 [Package] DataViews /packages/dataviews [Type] Enhancement A suggestion for improvement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants