chromaui / storybook-addon-pseudo-states

CSS pseudo-classes for Storybook
MIT License
88 stars 28 forks source link

Fix regression in pseudo-element handling #117

Closed m-akinc closed 4 months ago

m-akinc commented 4 months ago

When improving support for :not(), I had made a change that accidentally prevented rewriting rules that had pseudo-elements with pseudo-states applied, e.g. ::part(foo):active or ::-webkit-scrollbar-thumb:hover. Though we want to avoid generating selectors that apply classes to these pseudo-elements (it is invalid CSS), we still want to generate the selectors involving the .pseudo-<state>-all classes. Since we do not append those classes to the pseudo-elements (e.g. .pseudo-active-all ::part(foo)), they are valid CSS.

I have updated the tests to ensure we generate the .pseudo-<state>-all-based selectors, but not the .pseudo-<state>-based ones.

Even after this fix, I noticed that the ShadowRootWithPart story was not consistently being rendered properly. It turned out that the stylesheet rewrite was happening before the React.useEffect hook was inserting the styles into the element. By switching to including the styles by importing, the timing issue is resolved.

ghengeveld commented 4 months ago

Awesome, looks good now 👍

Maybe we need to address that useEffect issue, but it's beyond the scope of this change.

github-actions[bot] commented 4 months ago

:rocket: PR was released in v3.1.0 :rocket: