Skip to content

UI: improve component code readability in Storybook by using arrays for children - #80352

Merged
ciampo merged 2 commits into
trunkfrom
update/ui-storybook-children
Jul 16, 2026
Merged

UI: improve component code readability in Storybook by using arrays for children#80352
ciampo merged 2 commits into
trunkfrom
update/ui-storybook-children

Conversation

@simison

@simison simison commented Jul 16, 2026

Copy link
Copy Markdown
Member

Follow-up to #77382 (comment)

Alternative to #80129

Pairs with #80132 which adds displayNames.

What?

Avoid <React.Fragment> appearing in code examples by using [] instead of <> in Storybook examples.

Cleaner code previews and copy-paste for docs consumers.

How?

Testing Instructions

Run npm run storybook:dev
Smoke test different stories and code snippets.

Testing Instructions for Keyboard

Screenshots or screencast

Before

image image

After

Screenshot 2026-07-16 at 12 50 46 image

Use of AI Tools

yes

@simison
simison requested a review from a team as a code owner July 16, 2026 10:41
@simison simison added Storybook Storybook and its stories for components [Package] UI /packages/ui labels Jul 16, 2026
@github-actions

Copy link
Copy Markdown

Warning: Type of PR label mismatch

To merge this PR, it requires exactly 1 label indicating the type of PR. Other labels are optional and not being checked here.

  • Required label: Any label starting with [Type].
  • Labels found: Storybook, [Package] UI.

Read more about Type labels in Gutenberg. Don't worry if you don't have the required permissions to add labels; the PR reviewer should be able to help with the task.

1 similar comment
@github-actions

Copy link
Copy Markdown

Warning: Type of PR label mismatch

To merge this PR, it requires exactly 1 label indicating the type of PR. Other labels are optional and not being checked here.

  • Required label: Any label starting with [Type].
  • Labels found: Storybook, [Package] UI.

Read more about Type labels in Gutenberg. Don't worry if you don't have the required permissions to add labels; the PR reviewer should be able to help with the task.

@github-actions

github-actions Bot commented Jul 16, 2026

Copy link
Copy Markdown

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: simison <simison@git.wordpress.org>
Co-authored-by: ciampo <mciampini@git.wordpress.org>

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

@github-actions

Copy link
Copy Markdown

Size Change: 0 B

Total Size: 7.72 MB

compressed-size-action

@github-actions

Copy link
Copy Markdown

Flaky tests detected in 6770226.
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/29492196268
📝 Reported issues:

@ciampo ciampo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 🚀

Looks like a clean migration, let's try it out!

@ciampo

ciampo commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Given how prone to conflicts this PR is, I'll go ahead and merge

@ciampo
ciampo merged commit 3067f42 into trunk Jul 16, 2026
60 checks passed
@ciampo
ciampo deleted the update/ui-storybook-children branch July 16, 2026 16:34
@github-actions github-actions Bot added this to the Gutenberg 23.7 milestone Jul 16, 2026
@ciampo

ciampo commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Should we work on a small lint rule to encourage array notation over fragments in Storybook:

@aduth

aduth commented Jul 16, 2026

Copy link
Copy Markdown
Member

Another thing I was curious about but didn't have a chance to look is whether we actually need key here in the sense of why key matters in React. And if it's not a real problem to soften ESLint enforcement in these Story files. Feels like it's a slightly tedious aspect of maintaining these stories. At least glad they don't come through the code examples.

@ciampo

ciampo commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Another thing I was curious about but didn't have a chance to look is whether we actually need key here in the sense of why key matters in React. And if it's not a real problem to soften ESLint enforcement in these Story files. Feels like it's a slightly tedious aspect of maintaining these stories. At least glad they don't come through the code examples.

Good question. Something to investigate and potentially iterate on.

In general, I prefer tedious but correct / compliant code.

@ciampo

ciampo commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

We could maybe use Children.toArray([ … ]) which should allow us not to provide keys?

@jonathanbossenger jonathanbossenger added the [Type] Code Quality Issues or PRs that relate to code quality label Jul 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Package] UI /packages/ui Storybook Storybook and its stories for components [Type] Code Quality Issues or PRs that relate to code quality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants