Skip to content

Don't emit utilities that resolve a theme value when an unsupported modifier is used - #20419

Merged
RobinMalfait merged 7 commits into
tailwindlabs:mainfrom
webdevelopersrinu:fix/silently-dropped-modifiers
Aug 14, 2026
Merged

Don't emit utilities that resolve a theme value when an unsupported modifier is used#20419
RobinMalfait merged 7 commits into
tailwindlabs:mainfrom
webdevelopersrinu:fix/silently-dropped-modifiers

Conversation

@webdevelopersrinu

Copy link
Copy Markdown
Contributor

Summary

Modifiers on functional utilities that resolve a named theme value are silently
dropped instead of invalidating the candidate. For example, with the default theme:

  • rounded-sm/[5] emits the same CSS as rounded-sm (the [5] is ignored)
  • shadow-sm/foo, inset-shadow-sm/foo, text-shadow/foo, and drop-shadow/foo
    emit the full shadow CSS with the invalid foo modifier ignored

This is inconsistent with how every sibling code path behaves: rounded/foo,
rounded-[4px]/foo, rounded-sm/5, and drop-shadow-xl/foo all correctly
produce no output, because those paths check candidate.modifier.

This PR adds the missing guards:

  • In the generic functionalUtility handler, a candidate whose named value
    resolves from the theme now rejects modifiers (except fractions like w-1/2,
    where the modifier is part of the resolved value).
  • The shadow, inset-shadow, and text-shadow utilities now apply the same
    if (candidate.modifier && !alpha) return guard in their default-value,
    arbitrary-value, and named-size branches that drop-shadow already applies,
    and drop-shadow gets it in its default-value branch too.

Existing tests asserting candidates like drop-shadow/foo produce no output were
passing for the wrong reason: they run without a theme, so the theme lookup fails
before the modifier is ever considered. The new tests provide a theme so the
invalid modifier is what invalidates the candidate.

Test plan

  • Added assertions to the rounded, filter, shadow, inset-shadow, and
    text-shadow tests that compile candidates with invalid modifiers against a
    theme that defines the relevant values, and expect no output. All of them fail
    without the fix.
  • pnpm vitest run packages/tailwindcss/src/utilities.test.ts — 398 passed.

@webdevelopersrinu
webdevelopersrinu requested a review from a team as a code owner August 14, 2026 12:46
@greptile-apps

greptile-apps Bot commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains, and the previously reported changelog placeholder has been replaced with the correct PR link.

Reviews (5): Last reviewed commit: "update CHANGELOG" | Re-trigger Greptile

Comment thread CHANGELOG.md Outdated
@coderabbitai

coderabbitai Bot commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

Functional utilities now reject unsupported modifiers on resolved theme values unless the value is a fraction. Stroke-width resolution applies the same validation. Drop-shadow, text-shadow, shadow, and inset-shadow utilities reject invalid opacity modifiers across default, arbitrary, named, and theme-backed values. Tests cover these cases, and the changelog documents the fix.

Merge Risk: ⚪ Minimal · up to 0f5aa

The change prevents unsupported modifiers from emitting utilities. One arbitrary text-shadow case could use an additional regression test, but no actionable merge-blocking risk remains.

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change: rejecting utilities when unsupported modifiers would otherwise be ignored.
Description check ✅ Passed The description directly explains the modifier validation changes, affected utilities, test coverage, and test results.
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.

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: c7681f73-63e3-4892-ad83-9c6455b8d6d7

📥 Commits

Reviewing files that changed from the base of the PR and between 021b7fe and 1633e01.

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

Comment thread CHANGELOG.md Outdated
@webdevelopersrinu
webdevelopersrinu force-pushed the fix/silently-dropped-modifiers branch 2 times, most recently from e58dd03 to d979c6d Compare August 14, 2026 12:59
RobinMalfait and others added 7 commits August 14, 2026 16:14
…orted modifier is used

Modifiers on functional utilities that resolve a named theme value (e.g.
`rounded-sm/[5]`) were silently dropped instead of invalidating the
candidate, unlike every sibling code path which rejects them. The same
applied to the shadow family (`shadow-sm/foo`, `inset-shadow-sm/foo`,
`text-shadow/foo`, `drop-shadow/foo`), where the `if (candidate.modifier
&& !alpha) return` guard existed only in `drop-shadow`'s named-size and
arbitrary-value branches.
@RobinMalfait
RobinMalfait force-pushed the fix/silently-dropped-modifiers branch from d979c6d to 0f5aa7a Compare August 14, 2026 16:41
@RobinMalfait
RobinMalfait enabled auto-merge (squash) August 14, 2026 16:41

@RobinMalfait RobinMalfait left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

I updated the tests to make them part of the existing section where we expect the tests to fail.
I also added a missing case for the stroke-* utilities, because stroke-2/foo would also compiler otherwise.

Last but not least, I also split up your commit, just so I could easily verify that the tests were indeed failing before applying the fix.

Thanks again!

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 537d3b07-3e72-41f4-99c0-e4cbb8a3d5fb

📥 Commits

Reviewing files that changed from the base of the PR and between d979c6d and 0f5aa7a.

📒 Files selected for processing (3)
  • CHANGELOG.md
  • packages/tailwindcss/src/utilities.test.ts
  • packages/tailwindcss/src/utilities.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • CHANGELOG.md
  • packages/tailwindcss/src/utilities.ts

Comment on lines +27287 to +27290
'-text-shadow-[var(--value)]',
'text-shadow/foo',
'text-shadow-sm/foo',
],

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Test an arbitrary text-shadow value with a slash modifier.

-text-shadow-[var(--value)] only tests negation. It does not execute the arbitrary-value branch with candidate.modifier set. Add text-shadow-[var(--value)]/foo so this test fails if unsupported modifiers are accepted again.

Proposed test case
         '-text-shadow-[var(--value)]',
         'text-shadow/foo',
         'text-shadow-sm/foo',
+        'text-shadow-[var(--value)]/foo',
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
'-text-shadow-[var(--value)]',
'text-shadow/foo',
'text-shadow-sm/foo',
],
'-text-shadow-[var(--value)]',
'text-shadow/foo',
'text-shadow-sm/foo',
'text-shadow-[var(--value)]/foo',
],

@RobinMalfait
RobinMalfait merged commit 7a7f386 into tailwindlabs:main Aug 14, 2026
9 checks passed
@webdevelopersrinu

webdevelopersrinu commented Aug 15, 2026

Copy link
Copy Markdown
Contributor Author

Thank you @RobinMalfait for the quick review and merge, and for tidying up the test organization noted for next time. This was my first contribution to Tailwind CSS and the experience was great.

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.

2 participants