Skip to content

Conversation

RobinMalfait
Copy link
Member

@RobinMalfait RobinMalfait commented Oct 9, 2025

This PR fixes an issue where a compound variant with a modifier such as not-group-hover/name:flex would not generate anything because the /name modifier belongs to the not variant, and not the compounded group-hover variant.

This PR is a workaround (and definitely not perfect) by special casing the not, has, and in variants such that their modifiers are moved internally to the sub variant as-if the /name existed on group-hover.

We don't do it for other compound variants such as group and peer because then group-peer-focus/name:underline would result in a breaking change:

- .group-peer-focus\\/name\\:flex:is(:where(.group\\/name):is(:where(.peer):focus ~ *) *)
+ .group-peer-focus\/name\:flex:is(:where(.group):is(:where(.peer\/name):focus ~ *) *) 

In case the diff is not clear, the name has moved:
image

This is also a limited workaround, because if you need multiple modifiers it won't work. I would've loved to special case this inside the not, has, and in code that handles these variants, but we handle the variants in a depth-first way, so by the time you are handling the not variant, the sub variant was already handled...

In a perfect world, you can use something like not-group/name-hover but then it becomes unambiguous because is name the name, is name-hover?

Test plan

Added a new test that wouldn't generate anything before this fix.

Fixes: #15772

@RobinMalfait RobinMalfait marked this pull request as ready for review October 9, 2025 17:03
@RobinMalfait RobinMalfait requested a review from a team as a code owner October 9, 2025 17:03
These variants now forward modifiers, so we need to make sure that
parsing, and later re-printing results in the exact same thing as we
started with.
That way `not-group-hover/name:flex` is actually parsed as a `not` and a
`group-hover/name` instead of a `not/name` and `group-hover`.
@RobinMalfait RobinMalfait force-pushed the fix/not-variant-modifier branch from ca9bb06 to 31e6662 Compare October 9, 2025 17:17
@RobinMalfait RobinMalfait changed the title Move modifier of not and has variant to sub variant Move modifier of not-*, has-*, and in-* variant to sub variant Oct 9, 2025
@RobinMalfait RobinMalfait merged commit 3aadba7 into main Oct 9, 2025
7 checks passed
@RobinMalfait RobinMalfait deleted the fix/not-variant-modifier branch October 9, 2025 17:30
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.

The not- variant does not work as expected with named groups (group/{name})
2 participants