Skip to content

fix: properly handle pseudo element ordering#3485

Merged
segunadebayo merged 1 commit intochakra-ui:mainfrom
adbutterfield:fix/pseudo-element-condition-ordering
Mar 17, 2026
Merged

fix: properly handle pseudo element ordering#3485
segunadebayo merged 1 commit intochakra-ui:mainfrom
adbutterfield:fix/pseudo-element-condition-ordering

Conversation

@adbutterfield
Copy link
Contributor

I was just trying to update to latest version in my project and found another regression introduce in v0.34.0.

📝 Description

Fix pseudo-element conditions (::before, ::after) being placed before pseudo-class selectors in generated CSS when combined with mixed (array-based) conditions.

⛳️ Current behavior (updates)

When a pseudo-element condition like _before is combined with a mixed condition like _hover (defined as an array, e.g. hover: ['@media (hover: hover)', '&:is(:hover, ...)']), the generated CSS selector places the pseudo-element before the pseudo-class:

.class::before:is(:hover, ...) — invalid CSS

This was introduced in 0.54.0 when "mixed" was added to the condition type ordering array for the theme conditions fix (commit 57343c1). Mixed conditions moved from index -1 (not in array, sorted first) to index 4 (sorted after self-nesting pseudo-elements at index 1).

🚀 New behavior

Pseudo-element conditions always sort last among non-at-rule conditions in the selector chain, matching the CSS spec requirement:

.class:is(:hover, ...)::before — valid CSS

Adds an isPseudoElement check to the sort() method that pushes ::before, ::after, and other pseudo-elements to the end, regardless of other condition types.

💣 Is this a breaking change (Yes/No):

No

📝 Additional Information

New test case with 5 assertions covering _before/_after combined with mixed, simple, and array-wrapped conditions. Full @pandacss/core test suite passes (233/233).

@changeset-bot
Copy link

changeset-bot bot commented Mar 3, 2026

🦋 Changeset detected

Latest commit: 158e21e

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 21 packages
Name Type
@pandacss/core Patch
@pandacss/astro-plugin-studio Patch
@pandacss/generator Patch
@pandacss/node Patch
@pandacss/parser Patch
@pandacss/reporter Patch
@pandacss/studio Patch
@pandacss/dev Patch
@pandacss/mcp Patch
@pandacss/postcss Patch
@pandacss/config Patch
@pandacss/extractor Patch
@pandacss/is-valid-prop Patch
@pandacss/logger Patch
@pandacss/preset-atlaskit Patch
@pandacss/preset-base Patch
@pandacss/preset-open-props Patch
@pandacss/preset-panda Patch
@pandacss/shared Patch
@pandacss/token-dictionary Patch
@pandacss/types Patch

Not sure what this means? Click here to learn what changesets are.

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

@vercel
Copy link

vercel bot commented Mar 3, 2026

@adbutterfield is attempting to deploy a commit to the Chakra UI Team on Vercel.

A member of the Team first needs to authorize it.

@vercel
Copy link

vercel bot commented Mar 3, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
panda-docs Ready Ready Preview Mar 3, 2026 9:06am

Request Review

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like the changes in this file and the one below came from a pre-commit hook.

@anubra266 anubra266 requested a review from segunadebayo March 17, 2026 10:13
@segunadebayo segunadebayo merged commit 8fda1a5 into chakra-ui:main Mar 17, 2026
5 of 7 checks passed
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.

2 participants