Repository navigation
fix: split where mobile ends from who can swipe - #249
Merged
Merged
Conversation
therealsama
force-pushed
the
fix/mobile-breakpoint-in-rem
branch
3 times, most recently
from
September 6, 2026 06:04
e9eec9f to
c6da38d
Compare
therealsama
force-pushed
the
fix/mobile-breakpoint-in-rem
branch
3 times, most recently
from
September 6, 2026 10:26
af79f80 to
6514339
Compare
`useIsMobile` answered two questions with one media query, and each answer was
wrong for someone.
Shape — how much chrome fits in the header — asked 767px in px while every
style around it switched on 48rem, so any reader whose default font size is not
16px got one layout's chrome under the other's styling: at a 24px default the
pills grew icons at 900px that the packer had reserved nothing for. It now asks
the desktop side, `(min-width: 48rem)`, and inverts it, so mobile is the absence
of `md:` rather than a second edge that can drift past it. `rem` in a media
query is the browser's default font size and ignores `html { font-size }` — the
same rule `md:` follows.
Which tree mounts was the same query, and that is not a width question. The
swipe viewer binds touch and nothing else — no keys, no wheel, no buttons — so a
reader without a finger who lands in it cannot advance the feed at all. Width
put them there: by narrowing a window under 768px, and, once the query moved to
rem, at a 1100px window on a 24px default font, which is a low-vision desktop
reader sent to a gesture they have no way to perform. `useCanSwipe` asks for a
coarse primary pointer as well, in the form that leaves a touch laptop on the
list, and re-answers when a trackpad appears mid-session.
Two more places inferred the tree from width and now ask what they mean.
index.html bets on a layout before React exists, so the first paint does not
carry the other one's scrollbar; it asked `innerWidth < 768`, a third
formulation, and now asks both of the hook's questions verbatim. The padding
keeping the network bar off the document scroller is the list's alone, since
swipe panels reserve that strip themselves — it moves onto `<main>`, which
already pads for the fixed header above it, and asks React which tree it is in.
The pre-paint class was the other candidate, and it cannot answer: a route
filter that matches every hash sets it on pages no viewer will ever mount, and
only a viewer takes it off, so an unrouted URL reserved nothing at all.
Asking React means React has to know, and one place had not been told. The
resolver that decides story-or-comment paints the viewer's own panel while it
waits, and that panel reserves the fixed chrome itself; it now declares swipe
mode before paint and releases it on the way out, the way the viewer's own hook
does. That also stops the skeleton starting a whole header below the story that
replaces it, which it did on every phone deep-link into an item.
Both of `<main>`'s reservations now measure the token they stand for. The
header's was `pt-14`, 3px more than `--header-height`, and a full-page state
sizes itself as the viewport minus both tokens — so the slack was 3px of scroll
on a page written to fit exactly.
The shared `matchMedia` stub answered `false` to everything, backwards for a
`min-width` question in a 1024px jsdom window. It answers width queries from
`window.innerWidth` now — through a getter, since the hook caches one list per
query for the module's life and a test that moves the viewport has to be able
to change the answer — and still answers `pointer` false, which is what makes
an unmocked `useCanSwipe` read as the mouse jsdom is.
Guards, each mutation-tested: the gate keeps the list for a mouse however narrow
the window and follows a pointer that changes; the layout question is asked in
rem, checked at the two viewports where px and rem disagree; the first paint
agrees with the hook in both directions, tested with the app's own scripts cut
so only the inline one can have set the class; and the bar's strip and the
header are each reserved exactly once, at the size of the token that stands for
them, in the viewer, in the list, and under a panel that has no viewer yet —
the list's case put to a full-page state, which fits the viewport only if both
of its reservations are those tokens.
Specs that simulated a phone by narrowing a desktop window now declare a finger,
which also runs the headline-selection guard on all four projects instead of
two. The navigation specs ask which tree mounted the way the app asks, and now
say which one they found: a headline is a visible link in either, so a branch
that only picked its waits could not fail.
therealsama
force-pushed
the
fix/mobile-breakpoint-in-rem
branch
from
September 6, 2026 11:01
6514339 to
1be79c1
Compare
therealsama
enabled auto-merge
September 6, 2026 13:16
kplachkov
approved these changes
Sep 6, 2026
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.
useIsMobileanswered two questions with one media query.Shape — how much chrome fits in the header — asked
767pxwhile every style around it switched on48rem, so anyone whose default font size isn't 16px got one layout's chrome under the other's styling. It now asks(min-width: 48rem)and inverts it, so mobile is the absence ofmd:rather than a second edge that can drift past it.Which tree mounts is not a width question. The swipe viewer binds touch and nothing else — no keys, no wheel, no buttons — so a reader without a finger who lands in it cannot advance the feed at all. Width put them there: by narrowing a window under 768px, which
maindoes today, and, once the query moved to rem, at a 1100px window on a 24px default font — a low-vision desktop reader sent to a gesture they have no way to perform.useCanSwipeasks for a coarse primary pointer as well, in the form that leaves a touch laptop on the list, and re-answers when a trackpad appears mid-session.Two more places inferred the tree from width and now ask what they mean:
index.htmlbets on a layout before React exists, so the first paint doesn't carry the other one's scrollbar. It askedinnerWidth < 768— a third formulation — and now asks both of the hook's questions verbatim.<main>, which already pads for the fixed header above it, and asks React which tree it is in. The pre-paint class was the other candidate and can't answer: a route filter matching every hash sets it on pages no viewer will mount, and only a viewer takes it off, so an unrouted URL reserved nothing at all.Asking React means React has to know, and the resolver that decides story-or-comment hadn't been told: it paints the viewer's own panel while it waits, and that panel reserves the fixed chrome itself. It now declares swipe mode before paint and releases it on the way out, the way the viewer's own hook does — which also stops the skeleton starting a whole header below the story that replaces it, as it did on every phone deep-link into an item.
Both of
<main>'s reservations now measure the token they stand for. The header's waspt-14, 3px more than--header-height, and a full-page state sizes itself as the viewport minus both tokens — so the slack was 3px of scroll on a page written to fit exactly.Guards are mutation-tested: the gate keeps the list for a mouse however narrow the window; the layout question is asked in rem at the two viewports where px and rem disagree; the first paint agrees with the hook in both directions, with the app's own scripts cut so only the inline one can have set the class; and the bar's strip and the header are each reserved exactly once, at the size of the token that stands for them — in the viewer, in the list, and under a panel with no viewer yet.
Specs that simulated a phone by narrowing a desktop window now declare a finger, which also runs the headline-selection guard on all four projects instead of two. The navigation specs ask which tree mounted the way the app asks, and now say which one they found: a headline is a visible link in either, so a branch that only picked its waits couldn't fail.