Skip to content

fix: guard against undefined theme size in Button for XS variant#2010

Open
akash-dabhi-qed wants to merge 1 commit intostrapi:mainfrom
akash-dabhi-qed:fix/2006-button-invalid-css-xs-size
Open

fix: guard against undefined theme size in Button for XS variant#2010
akash-dabhi-qed wants to merge 1 commit intostrapi:mainfrom
akash-dabhi-qed:fix/2006-button-invalid-css-xs-size

Conversation

@akash-dabhi-qed
Copy link
Copy Markdown

What does it do?

Adds a guard in ButtonWrapper's styled-component interpolation to return early when theme.sizes.button[$size] is undefined. Also replaces the raw Object.entries call with a safe loop that only emits @media blocks for known breakpoints.

Why is it needed?

The theme.sizes.button only defines entries for S, M, and L. When a Button is rendered with size="XS", the interpolation called Object.entries(undefined) which throws a runtime error and produces invalid CSS output in the stylesheet.

How to test it?

  1. Render a Button with size="XS" (e.g. in a Storybook story or unit test).
  2. Before this fix, the component throws and injects broken CSS.
  3. After this fix, the button renders without a height style (graceful fallback) and no error is thrown.

Related issue(s)/PR(s)

Fixes #2006

@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 15, 2026

@akash-dabhi-qed is attempting to deploy a commit to the Strapi Team on Vercel.

A member of the Team first needs to authorize it.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 15, 2026

⚠️ No Changeset found

Latest commit: 199cd76

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@sonarqubecloud
Copy link
Copy Markdown

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug]: Invalid CSS in Button component

1 participant