Skip to content

Don't drop the rest of a media query when migrating screen(…) - #20774

Open
NotAFlightRisk wants to merge 1 commit into
tailwindlabs:mainfrom
NotAFlightRisk:upgrade-media-screen-query
Open

NotAFlightRisk wants to merge 1 commit into
tailwindlabs:mainfrom
NotAFlightRisk:upgrade-media-screen-query

Conversation

@NotAFlightRisk

Copy link
Copy Markdown

Summary

Upgrading a v3 stylesheet with @media screen(md) and (orientation: landscape) gives you @media (width >= theme(--breakpoint-md)), so the orientation condition is just dropped. The codemod swaps the whole media query for the breakpoint, where v3 only ever replaced the screen(…) call. And since v4 doesn't support screen() at all, nothing catches it once the file's been rewritten.

Now it only replaces the screen(…) calls, which also keeps the print in @media print, screen(lg). Screens it can't resolve are left alone like before.

Test plan

Added a test for screen(md) and (orientation: landscape). It fails on main and passes with the fix, along with the other tests in the file:

npx vitest run --project @tailwindcss/upgrade packages/@tailwindcss-upgrade/src/codemods/css/migrate-media-screen.test.ts

@NotAFlightRisk
NotAFlightRisk requested a review from a team as a code owner November 28, 2026 19:16
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.

1 participant