Skip to content

fix: split where mobile ends from who can swipe - #249

Merged
therealsama merged 1 commit into
mainfrom
fix/mobile-breakpoint-in-rem
Sep 6, 2026
Merged

therealsama merged 1 commit into
mainfrom
fix/mobile-breakpoint-in-rem

Conversation

@therealsama

@therealsama therealsama commented Sep 5, 2026 •

Copy link
Copy Markdown
Collaborator

useIsMobile answered two questions with one media query.

Shape — how much chrome fits in the header — asked 767px while every style around it switched on 48rem, 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 of md: 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 main does 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. 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 doesn't 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 belongs to the list 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 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 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.

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.

Base automatically changed from fix/header-active-pill-narrow-fit to main September 5, 2026 18:35
@therealsama
therealsama force-pushed the fix/mobile-breakpoint-in-rem branch 3 times, most recently from e9eec9f to c6da38d Compare September 6, 2026 06:04
@therealsama therealsama changed the title fix: ask Tailwind's question about where mobile ends fix: split where mobile ends from who can swipe Sep 6, 2026
@therealsama
therealsama force-pushed the fix/mobile-breakpoint-in-rem branch 3 times, most recently from af79f80 to 6514339 Compare September 6, 2026 10:26
`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
therealsama force-pushed the fix/mobile-breakpoint-in-rem branch from 6514339 to 1be79c1 Compare September 6, 2026 11:01
@therealsama
therealsama merged commit 38e57e5 into main Sep 6, 2026
4 checks passed
@therealsama
therealsama deleted the fix/mobile-breakpoint-in-rem branch September 6, 2026 13:18
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