Skip to content

fix(badge): ensure fullWidth Button children render correctly - #8229

Merged
kaitlyn-owen merged 3 commits into
masterfrom
FE-7814
Oct 22, 2026
Merged

kaitlyn-owen merged 3 commits into
masterfrom
FE-7814

Conversation

@kaitlyn-owen

Copy link
Copy Markdown
Contributor

fix #8202

Proposed behaviour

fixed issue where fullWidth Button children don't extend there full width when wrapped in a badge
image

Current behaviour

fullWidth Buttons' layouts break when used in Badge
image

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

see WithFullWidthButtons for fix

${$fullWidth &&
css`
width: 100%;
[data-role="badge-wrapper"]:has(> &) {

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.

suggestion: could we apply a data- tag on Button when fullWidth is applied and then add the width in Badge instead?

tomdavies73
tomdavies73 previously approved these changes Oct 16, 2026
chromatic: { disableSnapshot: false },
};

export const WithFullWidthButtons: Story = () => {

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.

suggestion: Sorry I missed this first time around but it looks like this story we've added won't trigger a snapshot.

In the root of the file we set { disableSnapshot: true } and don't override it here. I think we need to override it here to make sure the snapshot is triggered.

This may be slightly out of scope but you could count up the stories which have { disableSnapshot: false } on them, if there are more stories being overriden than not you could flip the logic in the file.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Hi, I've made the suggested changes and updated the PR. Could I get another review please? Thanks :)

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

Happy to approve once the comment about the Chromatic snapshot by @tomdavies73 has been addressed 👍🏻

tomdavies73
tomdavies73 previously approved these changes Oct 19, 2026
padding: "var(--global-space-layout-xs)",
backgroundColor: "rgb(242, 245, 246)",
};
// import { Sizes } from "./badge.stories";

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.

nitpick: Commented out code has been left in here.

Suggested change
// import { Sizes } from "./badge.stories";

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ah thank you for spotting this! I will remove that now

tomdavies73
tomdavies73 previously approved these changes Oct 19, 2026
DipperTheDan
DipperTheDan previously approved these changes Oct 19, 2026
@DipperTheDan
DipperTheDan marked this pull request as ready for review October 19, 2026 12:52
@DipperTheDan
DipperTheDan requested review from a team as code owners October 19, 2026 12:52

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

Hi Kaitlyn, nice work on this, just the one comment from me, all looks good otherwise.

};

const meta: Meta<typeof Badge> = {
title: "Badge/Test",

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.

nitpick: As we have enabled the snapshot in this file, can we disable the none theme to just leave us with the sage one as it's not really needed?
We should be able to add a line similar to themeProvider: { chromatic: { theme: "sage" } },
You can see the pattern of this in the pager-test.stories.tsx

Image

tomdavies73
tomdavies73 previously approved these changes Oct 20, 2026
DipperTheDan
DipperTheDan previously approved these changes Oct 20, 2026
@kaitlyn-owen
kaitlyn-owen marked this pull request as ready for review October 20, 2026 15:07
paulrobinson88
paulrobinson88 previously approved these changes Oct 20, 2026
DipperTheDan
DipperTheDan previously approved these changes Oct 21, 2026
tomdavies73
tomdavies73 previously approved these changes Oct 21, 2026
@tomdavies73
tomdavies73 marked this pull request as ready for review October 21, 2026 13:06
fixed issue where fullWidth Button children don't extend their full width when wrapped in a badge

fix #8202
@kaitlyn-owen
kaitlyn-owen merged commit 1d451df into master Oct 22, 2026
30 checks passed
@kaitlyn-owen
kaitlyn-owen deleted the FE-7814 branch October 22, 2026 10:50
@carbonci

Copy link
Copy Markdown
Collaborator

🎉 This PR is included in version 162.16.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

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.

Badge component breaks children style

5 participants