Scope breakpoint media queries to screen so printing does not look like a resize - #81367
Merged
Conversation
Mamaduka
force-pushed
the
fix/media-queries-scope
branch
from
August 9, 2026 14:00
e967bc9 to
248f576
Compare
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
manzoorwanijk
approved these changes
Aug 9, 2026
|
Size Change: +13 B (0%) Total Size: 7.82 MB 📦 View Changed
|
Member
|
No sidebar jumping now BeforeKapture.2026-08-10.at.08.45.39.mp4AfterKapture.2026-08-10.at.08.47.08.mp4 |
ramonjd
approved these changes
Aug 9, 2026
Member
Author
|
Thanks for the reviews, folks! |
shail-mehta
pushed a commit
that referenced
this pull request
Aug 12, 2026
…ke a resize (#81367) Co-authored-by: Mamaduka <mamaduka@git.wordpress.org> Co-authored-by: manzoorwanijk <manzoorwanijk@git.wordpress.org> Co-authored-by: ramonjd <ramonopoly@git.wordpress.org> Co-authored-by: tellthemachines <isabel_brison@git.wordpress.org>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What?
PR fixes an unusual bug that I discovered by accident. Printing currently closes and reopens the editor's complementary area. Scoping breakpoint media queries to
screenprevents the print pass from being interpreted as a switch to a mobile viewport.Why?
Opening the browser print dialog re-evaluates the width media features against the page box rather than the window. Letter or A4 minus default margins is roughly 720 to 740 CSS px, which is under the 782px
mediumbreakpoint, so(max-width: 782px)flips to true and back.window.innerWidthnever changes and noresizeevent fires, so nothing else signals that anything happened.Both breakpoint query builders omit the media type, so they match paged media too. That means printing runs the editor's big-to-small path.
useAdjustComplementaryListenerseesisSmallbecome true, callsdisableComplementaryArea, then reopens the area afterward. Printing mutates the editor state, and the reopen animation is the visible symptom. Anything else keyed on viewport matching gets the same spurious event.How?
Build the queries as
screen and (min-width: Npx)in both places where they are generated.@wordpress/viewport's listener is the one that closed the sidebar, sinceisSmallreads from that store.useViewportMatchhas the same flaw and the same fix.Testing Instructions
Screenshots or screencast
CleanShot.2026-08-09.at.17.53.32.mp4
Use of AI Tools
Assisted by Claude.