Ensure custom --spacing-* values don't shadow spacing utility keywords - #20394
Ensure custom --spacing-* values don't shadow spacing utility keywords#20394thejamesgore wants to merge 3 commits into
Conversation
Signed-off-by: James Gore <83005220+thejamesgore@users.noreply.github.com>
|
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 (1)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughFunctional utilities now support fallback theme namespaces for resolution and suggestions. Static values take precedence over fallback matches. Spacing utilities use namespaces before 🚥 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 |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/tailwindcss/src/utilities.test.ts (1)
25736-25739: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winCover explicit
--leading-noneprecedence.Add
--leading-noneto this theme and assert thatleading-noneuses it. This locks the required primary-theme precedence over the static value.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 9b38bd47-531e-49b4-9db1-8a68e7c2ca32
📒 Files selected for processing (2)
packages/tailwindcss/src/utilities.test.tspackages/tailwindcss/src/utilities.ts
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains. Reviews (3): Last reviewed commit: "Cover explicit --leading-none precedence..." | Re-trigger Greptile |
Signed-off-by: James Gore <83005220+thejamesgore@users.noreply.github.com>
Fixes #19722
This has been open a while and the existing fix attempt went stale — it was created via an automated agent and is flawed IMO, so gave it a crack.
If you define a custom named spacing value like
--spacing-none: 0,leading-nonestarts outputtingline-height: 0instead ofline-height: 1.The
leadingutility resolves theme values against['--leading', '--spacing']before it ever falls back to the staticnonekeyword, so the custom spacing value wins the lookup and the keyword is never reached.The fix splits a spacing utility's theme keys into its own namespaces and the generic
--spacingfallback, and checksstaticValuesbetween the two. Setting--leading-noneexplicitly still overrides everything, which keeps the documented way of customising it working.leadingis the only spacing utility that usesstaticValuesso nothing else changes behaviour.Worth noting #19773 is the earlier attempt. I've scoped this one to just the spacing utilities rather than changing value resolution for every functional utility based on first key position, plus that PR had a few other issues — I left a comment on the thread (#19722 (comment)) to have some discussion on the best approach.
For testing I added a new case to the
leadingtest with--spacing-none: 0and--spacing-big: 3rem—leading-noneemitsline-height: 1andleading-bigemitsvar(--spacing-big). It fails onmain(you getline-height: var(--spacing-none)) and passes with the fix. The existing--leading-none: 2override test is untouched and still green, and the fullpackages/tailwindcsssuite passes locally.