Addon-Pseudo-States: Fix pseudo-states rewriting for nested functional selectors - #34318
Conversation
|
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)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthrough
ChangesPseudo-state selector rewriting
Estimated code review effort: 2 (Simple) | ~10 minutes Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint install failed. For unrecoverable errors, disable the tool in CodeRabbit configuration. 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 |
|
Hi @filipw01, Thank you for your contribution. Due to the high volume of incoming PRs, we are gently requesting that you either link a GitHub issue to the PR or provide a simple reproduction, ideally with a video or image showing the issue and its resolution! Thank you very much! |
Package BenchmarksCommit: The following packages have significant changes to their size or dependencies:
|
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 11 | 13 | 🚨 +2 🚨 |
| Self size | 107 KB | 191 KB | 🚨 +84 KB 🚨 |
| Dependency size | 2.74 MB | 2.89 MB | 🚨 +146 KB 🚨 |
| Bundle Size Analyzer | Link | Link |
storybook-addon-pseudo-states
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 0 | 0 | 0 |
| Self size | 24 KB | 21 KB | 🎉 -3 KB 🎉 |
| Dependency size | 686 B | 689 B | 🚨 +3 B 🚨 |
| Bundle Size Analyzer | Link | Link |
@storybook/addon-vitest
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 2 | 2 | 0 |
| Self size | 466 KB | 429 KB | 🎉 -36 KB 🎉 |
| Dependency size | 350 KB | 350 KB | 🚨 +3 B 🚨 |
| Bundle Size Analyzer | Link | Link |
@storybook/builder-vite
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 1 | 11 | 🚨 +10 🚨 |
| Self size | 136 KB | 136 KB | 🎉 -364 B 🎉 |
| Dependency size | 28 KB | 1.33 MB | 🚨 +1.30 MB 🚨 |
| Bundle Size Analyzer | Link | Link |
@storybook/builder-webpack5
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 182 | 182 | 0 |
| Self size | 92 KB | 79 KB | 🎉 -13 KB 🎉 |
| Dependency size | 37.43 MB | 37.43 MB | 🚨 +9 B 🚨 |
| Bundle Size Analyzer | Link | Link |
storybook
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 73 | 73 | 0 |
| Self size | 22.04 MB | 21.39 MB | 🎉 -650 KB 🎉 |
| Dependency size | 31.20 MB | 30.98 MB | 🎉 -218 KB 🎉 |
| Bundle Size Analyzer | Link | Link |
@storybook/angular
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 185 | 185 | 0 |
| Self size | 267 KB | 160 KB | 🎉 -107 KB 🎉 |
| Dependency size | 30.29 MB | 30.28 MB | 🎉 -13 KB 🎉 |
| Bundle Size Analyzer | Link | Link |
@storybook/angular-vite
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 20 | 29 | 🚨 +9 🚨 |
| Self size | 23.08 MB | 22.83 MB | 🎉 -247 KB 🎉 |
| Dependency size | 11.49 MB | 12.69 MB | 🚨 +1.21 MB 🚨 |
| Bundle Size Analyzer | Link | Link |
@storybook/ember
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 181 | 181 | 0 |
| Self size | 13 KB | 13 KB | 🎉 -15 B 🎉 |
| Dependency size | 32.79 MB | 32.77 MB | 🎉 -13 KB 🎉 |
| Bundle Size Analyzer | Link | Link |
@storybook/html-vite
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 4 | 14 | 🚨 +10 🚨 |
| Self size | 22 KB | 22 KB | 🚨 +4 B 🚨 |
| Dependency size | 199 KB | 1.50 MB | 🚨 +1.30 MB 🚨 |
| Bundle Size Analyzer | Link | Link |
@storybook/nextjs
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 536 | 527 | 🎉 -9 🎉 |
| Self size | 641 KB | 641 KB | 🎉 -174 B 🎉 |
| Dependency size | 64.69 MB | 64.14 MB | 🎉 -549 KB 🎉 |
| Bundle Size Analyzer | Link | Link |
@storybook/nextjs-vite
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 101 | 94 | 🎉 -7 🎉 |
| Self size | 1.42 MB | 1.42 MB | 🎉 -922 B 🎉 |
| Dependency size | 23.32 MB | 23.90 MB | 🚨 +580 KB 🚨 |
| Bundle Size Analyzer | Link | Link |
@storybook/preact-vite
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 4 | 14 | 🚨 +10 🚨 |
| Self size | 12 KB | 12 KB | 🚨 +4 B 🚨 |
| Dependency size | 217 KB | 1.52 MB | 🚨 +1.30 MB 🚨 |
| Bundle Size Analyzer | Link | Link |
@storybook/react-native-web-vite
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 122 | 125 | 🚨 +3 🚨 |
| Self size | 29 KB | 29 KB | 🎉 -13 B 🎉 |
| Dependency size | 25.71 MB | 25.91 MB | 🚨 +204 KB 🚨 |
| Bundle Size Analyzer | Link | Link |
@storybook/react-vite
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 79 | 83 | 🚨 +4 🚨 |
| Self size | 32 KB | 32 KB | 🎉 -245 B 🎉 |
| Dependency size | 20.44 MB | 21.21 MB | 🚨 +770 KB 🚨 |
| Bundle Size Analyzer | Link | Link |
@storybook/server-webpack5
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 194 | 194 | 0 |
| Self size | 15 KB | 15 KB | 🚨 +17 B 🚨 |
| Dependency size | 38.70 MB | 38.69 MB | 🎉 -13 KB 🎉 |
| Bundle Size Analyzer | Link | Link |
@storybook/svelte-vite
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 11 | 20 | 🚨 +9 🚨 |
| Self size | 54 KB | 54 KB | 🚨 +16 B 🚨 |
| Dependency size | 25.47 MB | 26.67 MB | 🚨 +1.20 MB 🚨 |
| Bundle Size Analyzer | Link | Link |
@storybook/sveltekit
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 12 | 21 | 🚨 +9 🚨 |
| Self size | 56 KB | 56 KB | 🚨 +5 B 🚨 |
| Dependency size | 25.52 MB | 26.73 MB | 🚨 +1.20 MB 🚨 |
| Bundle Size Analyzer | Link | Link |
@storybook/tanstack-react
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 80 | 84 | 🚨 +4 🚨 |
| Self size | 132 KB | 113 KB | 🎉 -19 KB 🎉 |
| Dependency size | 20.47 MB | 21.24 MB | 🚨 +769 KB 🚨 |
| Bundle Size Analyzer | Link | Link |
@storybook/vue3-vite
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 94 | 103 | 🚨 +9 🚨 |
| Self size | 32 KB | 34 KB | 🚨 +3 KB 🚨 |
| Dependency size | 18.54 MB | 43.15 MB | 🚨 +24.62 MB 🚨 |
| Bundle Size Analyzer | Link | Link |
@storybook/web-components-vite
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 5 | 15 | 🚨 +10 🚨 |
| Self size | 19 KB | 19 KB | 🚨 +16 B 🚨 |
| Dependency size | 266 KB | 1.56 MB | 🚨 +1.30 MB 🚨 |
| Bundle Size Analyzer | Link | Link |
@storybook/cli
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 205 | 205 | 0 |
| Self size | 869 KB | 829 KB | 🎉 -40 KB 🎉 |
| Dependency size | 87.61 MB | 86.73 MB | 🎉 -879 KB 🎉 |
| Bundle Size Analyzer | Link | Link |
@storybook/codemod
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 198 | 198 | 0 |
| Self size | 44 KB | 32 KB | 🎉 -12 KB 🎉 |
| Dependency size | 86.08 MB | 85.21 MB | 🎉 -869 KB 🎉 |
| Bundle Size Analyzer | Link | Link |
create-storybook
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 74 | 74 | 0 |
| Self size | 1.09 MB | 1.09 MB | 🚨 +1 KB 🚨 |
| Dependency size | 53.24 MB | 52.38 MB | 🎉 -869 KB 🎉 |
| Bundle Size Analyzer | node | node |
@storybook/csf-plugin
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 0 | 9 | 🚨 +9 🚨 |
| Self size | 0 B | 7 KB | 🚨 +7 KB 🚨 |
| Dependency size | 0 B | 1.29 MB | 🚨 +1.29 MB 🚨 |
| Bundle Size Analyzer | Link | Link |
@storybook/mcp
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 11 | 11 | 0 |
| Self size | 151 KB | 107 KB | 🎉 -43 KB 🎉 |
| Dependency size | 2.74 MB | 2.74 MB | 🚨 +896 B 🚨 |
| Bundle Size Analyzer | Link | Link |
@storybook/react
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 59 | 59 | 0 |
| Self size | 1.46 MB | 1.48 MB | 🚨 +16 KB 🚨 |
| Dependency size | 12.28 MB | 12.28 MB | 🚨 +13 B 🚨 |
| Bundle Size Analyzer | Link | Link |
@storybook/vue3
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 90 | 4 | 🎉 -86 🎉 |
| Self size | 184 KB | 68 KB | 🎉 -116 KB 🎉 |
| Dependency size | 18.11 MB | 584 KB | 🎉 -17.53 MB 🎉 |
| Bundle Size Analyzer | Link | Link |
|
@valentinpalkovic this is an error I'm getting in storybook, the best reproduction is the test I added in the PR. It's failing without my changes |
|
Sorry for the delay in reviewing this PR, @filipw01! We had a similar one come in and I thought I had merged yours. Could you please look at the conflicts? The other PR also handles |
cab8034 to
ddbccf6
Compare
…as-rewrite # Conflicts: # code/addons/pseudo-states/src/preview/rewriteStyleSheet.ts
|
@Sidnioulz Done, I think that should be good |
LogDetails |

What I did
Fixed
storybook-addon-pseudo-statesrewriting for pseudo states nested inside functional selectors like:has(span + :hover).Previously it would try to insert
:has(span > )which is an invalid selectorChecklist for Contributors
Testing
The changes in this PR are covered in the following automated tests:
Manual testing
Caution
This section is mandatory for all contributions. If you believe no manual test is necessary, please state so explicitly. Thanks!
Manual testing not performed in a Storybook sandbox.
storybook-addon-pseudo-statesin a Storybook instance.:has(span > :hover)and enable hover pseudo state.insertRule()error is thrown and the rewritten selector behaves as expected.Documentation
MIGRATION.MD
Checklist for Maintainers
When this PR is ready for testing, make sure to add
ci:normal,ci:mergedorci:dailyGH label to it to run a specific set of sandboxes. The particular set of sandboxes can be found incode/lib/cli-storybook/src/sandbox-templates.tsMake sure this PR contains one of the labels below:
Available labels
bug: Internal changes that fixes incorrect behavior.maintenance: User-facing maintenance tasks.dependencies: Upgrading (sometimes downgrading) dependencies.build: Internal-facing build tooling & test updates. Will not show up in release changelog.cleanup: Minor cleanup style change. Will not show up in release changelog.documentation: Documentation only changes. Will not show up in release changelog.feature request: Introducing a new feature.BREAKING CHANGE: Changes that break compatibility in some way with current major version.other: Changes that don't fit in the above categories.🦋 Canary release
This PR does not have a canary release associated. You can request a canary release of this pull request by mentioning the
@storybookjs/coreteam here.core team members can create a canary release here or locally with
gh workflow run --repo storybookjs/storybook publish.yml --field pr=<PR_NUMBER>Summary by CodeRabbit
:has()).:has()selectors containing combinators.