Text: Apply both heading and paragraph CSS defenses unconditionally#77461
Text: Apply both heading and paragraph CSS defenses unconditionally#77461
Conversation
|
Size Change: -30 B (0%) Total Size: 7.75 MB 📦 View Changed
ℹ️ View Unchanged
|
|
Flaky tests detected in d177742. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/24576078180
|
|
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. |
What?
Apply both the heading and paragraph entries from the unlayered CSS defense module to every
Textrender, regardless of thevariantprop.Follow up to #76783. Surfaced by a comment on #77372.
Why?
Textdecouples typographic variant from rendered element via therenderprop, but the previous defense logic was gated on the variant name (heading-*orbody-*). That meant common.css styles leaked through whenever the variant and the rendered element didn't match, e.g.<Text variant="body-sm" render={ <h2 /> } />orBadge(which is abody-smTextrendered as a heading by consumers).How?
The heading and paragraph defenses in
global-css-defense.module.cssare already gated by compound selectors (p.pand:is(h1, h2, h3, h4, h5, h6).heading), so applying both classes unconditionally is a no-op when the element doesn't match. Drop the variant-based gating and let the selectors do the work.Testing Instructions
In Storybook, with the global CSS injector in the toolbar set to "WordPress", see the "With render prop" story for the
Textcomponent. Tweak the story file to render differentvariantandrendercombinations and see that there are no regressions.