Fix utility staticValues shadowed by fallback theme namespaces - #20423
Fix utility staticValues shadowed by fallback theme namespaces#20423koreahghg wants to merge 1 commit into
Conversation
Utilities like `leading-none`, `columns-auto`, and `backdrop-blur-none` resolve their value against multiple theme namespaces, the first being their own dedicated namespace and the rest shared fallbacks (e.g. `--spacing`, `--container`, `--blur`). Their `staticValues` fallback only kicked in when nothing resolved at all, so a same-named custom theme value defined for a completely unrelated utility (e.g. `--spacing-none`) would silently win over the intended static value. Fixes tailwindlabs#19722
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review. WalkthroughUpdated Merge Risk: ⚪ Minimal · up to This localized fix corrects static utility values that could be shadowed by unrelated fallback theme values, with regression coverage for the affected cases; no actionable merge-blocking risk remains after normal checks and review. 🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
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 |
Confidence Score: 5/5The PR appears safe to merge with no actionable defects identified. The precedence adjustment is limited to the three intended multi-namespace utilities with static values, and the additional theme lookup is side-effect-free. Reviews (1): Last reviewed commit: "Fix staticValues being shadowed by unrel..." | Re-trigger Greptile |
|
Closing this — I hadn't seen #19773 and #20394 when I opened this. This PR uses the same approach as #19773 (treating #20394's scoped, opt-in approach ( |
Summary
Some functional utilities resolve their value against two theme namespaces: their own dedicated one, and a shared fallback used by many unrelated utilities (e.g.
leadinguses['--leading', '--spacing'],columnsuses['--columns', '--container'],backdrop-bluruses['--backdrop-blur', '--blur']). These utilities also definestaticValuesfor special keywords likenone/auto.The
staticValuesfallback only kicked in when the theme resolved to nothing at all across every key inthemeKeys. This means a same-named custom theme value defined for a completely different, unrelated utility silently wins over the intended static value:This fixes #19722 (
leading-noneshadowed by a custom--spacing-none), and also fixes two more previously unreported instances of the exact same root cause:columns-autoshadowed by a custom--container-auto(outputscolumns: 500pxinstead ofcolumns: auto)backdrop-blur-noneshadowed by a custom--blur-none(doesn't properly reset the backdrop blur)Fix:
functionalUtility()now also resolves the candidate against just the utility's own dedicated namespace (themeKeys[0]). AstaticValuesentry is only shadowed if that resolution (not the combined fallback resolution) finds a value — i.e. only when the utility's own namespace defines something for that name. A same-named value that only exists in a shared fallback namespace no longer suppresses the static value.Test plan
utilities.test.tsfor all three affected utilities (leading-none,columns-auto,backdrop-blur-none), each reproducing the shadowing with a colliding custom theme value and asserting the correct static output.pnpm vitest run packages/tailwindcss/src— all 5007 tests pass (1 pre-existing skip), no regressions from this change.