Fix !important modifier having no effect on native#534
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughInvokes toCamelCase(property) when mapping style property names during metadata serialization, and adds a Jest "Specificity" test that asserts resolved color outcomes for combinations of normal and ChangesStyle metadata and parsing tests
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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 skipped: no ESLint configuration detected in root package.json. To enable, add Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. 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 |
|
Hey, thanks for the PR. We've totally missed that 🙈 Could you create simple unit test for important properties? |
|
When multiple ! important modifiers are set to conflicting classes, the former wins currently. Is this expected or should this be fixed to prioritize the latter? For example, the |
It is fine how it is working now, we don't really focus on such niche cases |
|
🚀 This pull request is included in v1.6.5. See Release v1.6.5 for release notes. |
Problem
The Tailwind
!importantmodifier (e.g.,text-red-500!) has no effecton native platforms. Classes without the modifier always win regardless
of the
!flag.Root cause
In
addMetaToStylesTemplate.ts,toCamelCaseis passed as a valueinstead of being called as a function when mapping
importantProperties:This means the
importantPropertiesarray ends up containing thetoCamelCasefunction reference instead of the camelCased property namestring (e.g.,
"color").At runtime, the store checks:
This compares a string like
"color"against an array containing afunction reference, so it never matches and the
!importantguardsilently fails.
Fix
Summary by CodeRabbit
Bug Fixes
Tests