Skip to content

Components: migrate StyledLabel to SCSS module - #80001

Open
im3dabasia wants to merge 15 commits into
WordPress:trunkfrom
im3dabasia:try/migrate-style-label-to-css
Open

Components: migrate StyledLabel to SCSS module#80001
im3dabasia wants to merge 15 commits into
WordPress:trunkfrom
im3dabasia:try/migrate-style-label-to-css

Conversation

@im3dabasia

Copy link
Copy Markdown
Contributor

What?

Part of #66806

Migrates StyledLabel away from Emotion and onto an SCSS Module, while preserving the existing as="legend" behavior used by FocalPointPicker, BorderControl, and related consumers.

Why?

StyledLabel is one of the representative styled components that relies on Emotion’s native as support without going through View. Migrating it helps validate the non-Emotion polymorphic pattern for shared label primitives and removes another piece of Emotion usage from @wordpress/components.

How?

  • Adds a style.module.scss for the shared BaseControl label/help styles.
  • Replaces the Emotion styled.* exports with PolymorphicElement-based wrapper components.
  • Updates border-control and tools-panel to target stable BaseControl class names instead of Emotion component interpolation.
  • Adds a dedicated E2E assertion for the legend path via the Cover block focal point picker.

Testing Instructions

  • npm run test:unit -- packages/components/src/base-control/test/index.tsx
  • npm run test:unit -- packages/components/src/border-control/test/index.js
  • npm run test:e2e -- section-block-style-panels.spec.js --project=chromium
  • npm run test:e2e -- taxonomies.spec.js --project=chromium
  • npm run test:e2e -- cover.spec.js --project=chromium --grep "legend-labelled group"

Use of AI Tools

Used GitHub Copilot to help plan the migration, update the shared BaseControl style surface, and add focused test coverage. All generated changes were reviewed and validated manually.

@github-actions github-actions Bot added [Package] Components /packages/components [Package] Editor /packages/editor [Package] Block editor /packages/block-editor [Package] Edit Post /packages/edit-post labels Jul 8, 2026
@im3dabasia
im3dabasia force-pushed the try/migrate-style-label-to-css branch from 3a815c3 to 3d497b7 Compare July 8, 2026 12:58
@im3dabasia im3dabasia added the [Type] Code Quality Issues or PRs that relate to code quality label Jul 8, 2026
@im3dabasia
im3dabasia marked this pull request as ready for review July 9, 2026 03:35
@im3dabasia
im3dabasia requested review from a team, ajitbohra and ellatrix as code owners July 9, 2026 03:35
@github-actions

github-actions Bot commented Jul 9, 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: im3dabasia <im3dabasia1@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.

@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.

Thank you for working on this 🙏

On top of inline comments, some general feedback:

  • looks like we should re-generate snapshots throughout the repo.
  • we're missing a CHANGELOG entry

Comment thread packages/components/src/base-control/styles/base-control-styles.tsx Outdated
Comment thread packages/components/src/base-control/styles/base-control-styles.tsx Outdated
@ciampo

ciampo commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Hello @im3dabasia ! do you have capacity to continue the work on this PR?

@im3dabasia

Copy link
Copy Markdown
Contributor Author

@ciampo,

Yeah, I'll work on this PR and ping you by the end of the day once I've addressed all the feedback.

@im3dabasia

Copy link
Copy Markdown
Contributor Author

Hi @ciampo,

Hopefully 🤞 the CI will be happy now, and I've addressed all of your feedback as well. Apologies for the delay.

Over to you! Could you please review the PR and let me know if there's anything else you'd like me to change?

@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.

Hopefully 🤞 the CI will be happy now

It won't be until we update the stale ESLint suppressions 😄

text-transform: uppercase;
}

.help {

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.

I believe we're missing text-wrap: pretty compared to the previous implementation?


return (
<Wrapper className={ className }>
<Wrapper className={ clsx( 'components-base-control', className ) }>

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.

The regenerated snapshots now contain duplicated public classes, for example:

class="style-wrapper components-base-control components-base-control"
class="style-field components-base-control__field components-base-control__field"

That is not trunk-equivalent. useContextSystem( props, 'BaseControl' ) already supplies components-base-control in className, and trunk already passed components-base-control__field from the BaseControl call site. We should avoid baking those same classes into both sides of the migration.

The narrower trunk-parity fix is:

  • keep <Wrapper className={ className }> in BaseControl
  • keep <StyledField className="components-base-control__field"> in BaseControl
  • remove 'components-base-control__field' from UnforwardedStyledField

That should remove the duplicate classes from snapshots while preserving the public classes where they existed before.

<PolymorphicElement
ref={ ref }
{ ...props }
className={ clsx(

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.

Same here re. duplicate class names

@im3dabasia im3dabasia self-assigned this Jul 20, 2026
…label-to-css

# Conflicts:
#	packages/components/src/toggle-group-control/test/__snapshots__/index.tsx.snap
@im3dabasia
im3dabasia requested a review from ciampo July 20, 2026 13:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Package] Block editor /packages/block-editor [Package] Components /packages/components [Package] Edit Post /packages/edit-post [Package] Editor /packages/editor [Type] Code Quality Issues or PRs that relate to code quality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants