Skip to content

Fix utility staticValues shadowed by fallback theme namespaces - #20423

Closed
koreahghg wants to merge 1 commit into
tailwindlabs:mainfrom
koreahghg:fix/static-value-fallback-namespace-shadowing
Closed

Fix utility staticValues shadowed by fallback theme namespaces#20423
koreahghg wants to merge 1 commit into
tailwindlabs:mainfrom
koreahghg:fix/static-value-fallback-namespace-shadowing

Conversation

@koreahghg

Copy link
Copy Markdown
Contributor

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. leading uses ['--leading', '--spacing'], columns uses ['--columns', '--container'], backdrop-blur uses ['--backdrop-blur', '--blur']). These utilities also define staticValues for special keywords like none/auto.

The staticValues fallback only kicked in when the theme resolved to nothing at all across every key in themeKeys. This means a same-named custom theme value defined for a completely different, unrelated utility silently wins over the intended static value:

@theme {
  --spacing-none: 0; /* meant for spacing utilities, e.g. p-none */
}
<p class="leading-none">...</p>
<!-- outputs line-height: var(--spacing-none) → 0, instead of the intended line-height: 1 -->

This fixes #19722 (leading-none shadowed by a custom --spacing-none), and also fixes two more previously unreported instances of the exact same root cause:

  • columns-auto shadowed by a custom --container-auto (outputs columns: 500px instead of columns: auto)
  • backdrop-blur-none shadowed 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]). A staticValues entry 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

  • Added regression tests in utilities.test.ts for 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.

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
@koreahghg
koreahghg requested a review from a team as a code owner August 20, 2026 00:02
@coderabbitai

coderabbitai Bot commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 35097086-efdd-4968-9565-3035d9e58f51

📥 Commits

Reviewing files that changed from the base of the PR and between 90f8ff4 and 8776458.

📒 Files selected for processing (2)
  • packages/tailwindcss/src/utilities.test.ts
  • packages/tailwindcss/src/utilities.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.


Walkthrough

Updated functionalUtility to distinguish a utility’s primary theme namespace from fallback namespaces when resolving candidate values. Static values remain available unless the primary namespace defines the candidate. Added regression tests for columns-auto, backdrop-blur-none, and leading-none with customized related theme variables.

Merge Risk: ⚪ Minimal · up to 87764

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)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the fix for static utility values being shadowed by fallback theme namespaces.
Description check ✅ Passed The description directly explains the bug, the implementation, the affected utilities, and the regression tests.
Linked Issues check ✅ Passed The change fixes issue #19722 and preserves static leading-none output while retaining fallback support for numeric leading values.
Out of Scope Changes check ✅ Passed The code and test changes are limited to the linked issue and its directly related fallback-namespace regressions.

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.

@greptile-apps

greptile-apps Bot commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5

The 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

@koreahghg

Copy link
Copy Markdown
Contributor Author

Closing this — I hadn't seen #19773 and #20394 when I opened this. This PR uses the same approach as #19773 (treating themeKeys[0] as the utility's own namespace generically in functionalUtility), which was already flagged as an overreach in the discussion on #19722 (it doesn't hold for utilities like min-h where more than one key is legitimately utility-specific, not just a generic fallback like --spacing).

#20394's scoped, opt-in approach (fallbackThemeKeys) looks like the right pattern here. I'll follow up separately, scoped just to the columns-auto/--container-auto and backdrop-blur-none/--blur-none cases, which aren't covered by #20394 since those utilities don't go through spacingUtility().

@koreahghg koreahghg closed this Aug 20, 2026
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.

[v4] Custom named --spacing-* values shadow leading-none staticValues (e.g. --spacing-none: 0 causes line-height: 0)

1 participant