Skip to content

Conversation

@p-jackson
Copy link
Member

What?

Fixes an accessibility error when providing a custom empty element.

Screenshot 2025-09-03 at 17 35 17

Why?

The custom empty element can be anything arbitrary, including divs and headings. These elements are not semantically allowed to be children of paragraphs.

Raised here #70867 (comment)

How?

If a dataviews user wants to have a wrapping paragraph for their custom message, they now need to provide their own. The margin provided by the paragraph element doesn't usually do anything, since the message is usually centred in a full height dataview in Gutenberg.

The spinner continues to be wrapped in a paragraph. This is allowed semantically (the spinner is just an element), it keeps the vertical margins of the spinner consistent with the default empty message, and it is consistent with the spinners which show when the dataviews are loading more data in infinite scroll mode.

Testing Instructions

There should be no visual changes.

You can check the custom messages in storybook. First run npm run storybook:dev. Then check out the custom empty message stories.

DataViews : Custom Empty

CleanShot 2025-09-09 at 22 08 04@2x

DataViews : Free Composition

CleanShot 2025-09-09 at 22 08 19@2x

Testing Instructions for Keyboard

No keyboard changes.

The custom empty element can be anything arbitrary, including divs and
headings. These elements are not semantically allowed to be children of
paragraphs.

The spinner continues to be wrapped in a paragraph. This is allowed
semantically (the spinner is just an <svg> element), it keeps the
vertical margins of the spinner consistent with the default empty
message, and it is consistent with the spinners which show when the
dataviews are loading more data in infinite scroll mode.
@p-jackson p-jackson self-assigned this Sep 9, 2025
@p-jackson p-jackson force-pushed the fix/a11y-dataviews-empty-message branch from f5893be to 8fec89d Compare September 9, 2025 10:10
@p-jackson p-jackson added [Type] Bug An existing feature does not function as intended [Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). [Feature] DataViews Work surrounding upgrading and evolving views in the site editor and beyond [Package] DataViews /packages/dataviews labels Sep 9, 2025
@p-jackson p-jackson marked this pull request as ready for review September 9, 2025 10:10
@p-jackson p-jackson requested a review from oandregal as a code owner September 9, 2025 10:10
@github-actions
Copy link

github-actions bot commented Sep 9, 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: p-jackson <[email protected]>
Co-authored-by: youknowriad <[email protected]>
Co-authored-by: andrewserong <[email protected]>

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

@github-actions
Copy link

github-actions bot commented Sep 9, 2025

Flaky tests detected in 8fec89d.
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/17579295497
📝 Reported issues:

>
<p>{ isLoading ? <Spinner /> : empty }</p>
{ isLoading ? (
<p>
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need "p" around the spinner?

Copy link
Member Author

Choose a reason for hiding this comment

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

Without the <p> it can cause a jump in the dataview content when the view flips from the loading state to the empty state, because the vertical margin from the <p> appears all of a sudden.

I'm being super extra paranoid about this particular case because the default spinner and empty message elements are what appear in the Gutenberg editor. And I definitely do not want to introduce visual changes to the Gutenberg editor while working on this standalone component.

Copy link
Contributor

Choose a reason for hiding this comment

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

And I definitely do not want to introduce visual changes to the Gutenberg editor while working on this standalone component.

I like this reasoning 👍

Copy link
Contributor

@youknowriad youknowriad left a comment

Choose a reason for hiding this comment

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

Not sure about needing the "p" around spinners but other than that. This LGTM

Copy link
Contributor

@andrewserong andrewserong left a comment

Choose a reason for hiding this comment

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

Thanks for the ping, LGTM too!

@p-jackson p-jackson merged commit bd51093 into trunk Sep 10, 2025
92 checks passed
@p-jackson p-jackson deleted the fix/a11y-dataviews-empty-message branch September 10, 2025 05:58
@github-actions github-actions bot added this to the Gutenberg 21.7 milestone Sep 10, 2025
adamsilverstein pushed a commit to adamsilverstein/gutenberg that referenced this pull request Sep 11, 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 [Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). [Package] DataViews /packages/dataviews [Type] Bug An existing feature does not function as intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants