Skip to content

fix: important with state specificity#585

Merged
Brentlok merged 1 commit into
mainfrom
fix/important-with-state
Jun 23, 2026
Merged

fix: important with state specificity#585
Brentlok merged 1 commit into
mainfrom
fix/important-with-state

Conversation

@Brentlok

@Brentlok Brentlok commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

#584

Summary by CodeRabbit

  • Bug Fixes
    • Fixed style precedence resolution for !important declarations combined with state variants, ensuring correct specificity handling when complexity levels differ.
@coderabbitai

coderabbitai Bot commented Jun 23, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: fd12a519-af92-4dfa-aa88-5db75fcc989d

📥 Commits

Reviewing files that changed from the base of the PR and between af3e7bf and 6475b10.

📒 Files selected for processing (2)
  • packages/uniwind/src/core/native/store.ts
  • packages/uniwind/tests/native/styles-parsing/specificity.test.tsx

📝 Walkthrough

Walkthrough

In resolveStyles, the previousBest.importantProperties check that blocks a new candidate is now gated on equal complexity between the previous best and the current style. A new specificity test covers !important combined with a focus: state variant, asserting correct backgroundColor transitions on focus and blur.

Changes

!important Precedence and State Variant Fix

Layer / File(s) Summary
resolveStyles precedence logic
packages/uniwind/src/core/native/store.ts
Refactors the single compound winner condition into an explicit previousWins flag; importantProperties now only suppresses the incoming candidate when previousBest.complexity === style.complexity.
!important + state variant test
packages/uniwind/tests/native/styles-parsing/specificity.test.tsx
Adds TextInput import and a new test that renders with bg-red-500! and focus:bg-blue-500!, fires focus/blur events, and asserts backgroundColor switches between red and blue theme values.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • uni-stack/uniwind#534: Fixes importantProperties camelCasing so the includes() check inside resolveStyles actually matches — directly upstream of the logic this PR adjusts.
  • uni-stack/uniwind#547: Modifies resolveStyles in the same file to refactor the computation model, touching the same winner-selection code path changed here.

Poem

🐇 In the garden of styles where importance reigns,
A focus can bloom and a blur fades the stains.
When complexities clash, old rules stepped aside,
Now equal in weight lets the !important decide.
Hop hop, the right color will always reside! 🌸

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly and clearly describes the main fix - addressing how important properties interact with state specificity, which matches the core changes in store.ts and the test additions.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/important-with-state

Warning

Tools execution failed with the following error:

Failed to run tools: 13 INTERNAL: Received RST_STREAM with code 2 (Internal server error)


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Brentlok Brentlok merged commit d7f3bd2 into main Jun 23, 2026
2 checks passed
@Brentlok Brentlok deleted the fix/important-with-state branch June 23, 2026 10:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant