fix(core): scope wildcard CSS in error display to prevent global style leak#34180
fix(core): scope wildcard CSS in error display to prevent global style leak#34180mango766 wants to merge 1 commit into
Conversation
The `*` selector inside `.sb-errordisplay_main` was missing the `&`
nesting combinator, causing some CSS processors to emit it as a global
`* { background: #fff; color: #000 }` rule in production builds. This
overrides component styles in the preview iframe.
Add the `&` prefix to match the pattern already used by
`.sb-nopreview_main`, ensuring the wildcard stays scoped to the error
display container.
Closes storybookjs#33735
Closes storybookjs#33947
Closes storybookjs#34036
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThis PR refines CSS scoping in the error display component by changing the universal selector from a global rule to a scoped selector, ensuring style resets apply only within the Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Possibly related PRs
📝 Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment Tip CodeRabbit can use your project's `biome` configuration to improve the quality of JS/TS/CSS/JSON code reviews.Add a configuration file to your project to customize how CodeRabbit runs |
|
Closing, since a PR already exists which attempts to solve all three mentioned GitHub issues: |
Closes #33735, closes #33947, closes #34036
What I did
Fixed a CSS nesting bug in
base-preview-head.htmlwhere the*selector inside.sb-errordisplay_mainwas missing the&nesting combinator. Without&, some CSS processors (particularly in Vite/Rolldown production builds) emit the rule as a global* { background: #fff; color: #000 }, which overrides component background/text styles in the preview iframe.The fix is a one-character change:
*→& *, matching the pattern already used by.sb-nopreview_maina few lines above.Before:
After:
Checklist for Contributors
Testing
The changes in this PR are covered in the following automated tests:
Manual testing
yarn task --task sandbox --start-from auto --template react-vite/default-tsnpx storybook build(production build)<style>content — verify there is no global* { background: #fff; color: #000 }ruleAlternatively, you can test with the
web-components-vitetemplate to reproduce the exact setup from #34036.Documentation
MIGRATION.MD
Summary by CodeRabbit