Skip to content

refactor(switch): remove legacy components and any legacy styles - FE-7888 - #8339

Draft
DipperTheDan wants to merge 2 commits into
masterfrom
FE-7888_remove-legacy-hinttext-switch
Draft

DipperTheDan wants to merge 2 commits into
masterfrom
FE-7888_remove-legacy-hinttext-switch

Conversation

@DipperTheDan

Copy link
Copy Markdown
Contributor

Proposed behaviour

Removes legacy hint text in favour of the current version of the component.

Current behaviour

Component still uses the legacy version of hint text.

Checklist

  • Commits follow our style guide
  • Related issues linked in commit messages if required
  • Screenshots are included in the PR if useful
  • All themes are supported if required
  • Unit tests added or updated if required
  • Playwright automation tests added or updated if required
  • Storybook added or updated if required
  • Translations added or updated (including creating or amending translation keys table in storybook) if required
  • Typescript d.ts file added or updated if required
  • Related docs have been updated if required

QA

  • Tested in provided StackBlitz sandbox/Storybook
  • Add new Playwright test coverage if required
  • Carbon implementation matches Design System/designs
  • UI Tests GitHub check reviewed if required

Additional context

Testing instructions

There should be no functional or visual regressions with Switch.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues block the Switch hint-text migration.

No open issues 🎉

1 file not reviewed
What changed in this PR

Updates Switch to use the current internal hint-text component instead of the legacy version.

Changes:

  • Applies size-aware typography, disabled styling, and spacing to supporting text.
  • Adds unit coverage and a focused-hints visual story.
  • Documents deprecated props and migration behavior.
File Description
src/​components/​switch/​switch.test.tsx Tests hint styling, fallback behavior, and accessible descriptions.
src/​components/​switch/​switch.style.tsx Adds styled hint wrappers with spacing.
src/​components/​switch/​switch.mdx Documents deprecated props and replacements.
src/​components/​switch/​switch.component.tsx Replaces legacy hints with current styled components.
src/​components/​switch/​switch-test.stories.tsx Adds focused switches with hints in both sizes.

Review effort: Balanced

@mihai-albu-sage

Copy link
Copy Markdown
Contributor

nitpick (non-blocking): Since the Switch now goes through the new HintText, switchHelpIcon and switchFieldHelp in playwright/components/switch/index.ts are looking for [data-component='help'] / [data-element='help'], which the Switch doesn't render anymore. Nothing uses them right now so nothing's broken, but if someone picks them up later they'll quietly match nothing.

Might be worth deleting them while you're here but it's totally fine to leave for a follow-up though since most of the other helpers in the file aren't used either.

mihai-albu-sage
mihai-albu-sage previously approved these changes Dec 4, 2026

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

Everything looks good! I just have a quick question about the tests. Since jsdom doesn't actually render CSS, these assertions are only checking the code itself rather than what the browser paints - meaning a test would still pass even if a token is undefined in the theme. Given that this is already visually covered by the new chromatic story, do we still need these style assertions?

@DipperTheDan

Copy link
Copy Markdown
Contributor Author

Everything looks good! I just have a quick question about the tests. Since jsdom doesn't actually render CSS, these assertions are only checking the code itself rather than what the browser paints - meaning a test would still pass even if a token is undefined in the theme. Given that this is already visually covered by the new chromatic story, do we still need these style assertions?

No, I’ll drop the new toHaveStyleRule assertions from the Switch tests. Good catch and nice thinking 👍🏻

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

4 participants