Repository navigation
feat: sharpen touch feel across the mobile swipe feed - #227
Merged
Merged
Conversation
therealsama
force-pushed
the
feat/mobile-touch-feel
branch
from
August 28, 2026 18:18
b56e8e1 to
ababd55
Compare
therealsama
force-pushed
the
feat/mobile-touch-feel
branch
6 times, most recently
from
August 29, 2026 18:11
a160b4a to
b04e134
Compare
therealsama
force-pushed
the
feat/mobile-touch-feel
branch
3 times, most recently
from
September 2, 2026 04:22
7026195 to
f37041f
Compare
Five defects that each broke the illusion of a native feed on a phone. The first four are gesture and feedback gaps on a touch pointer; the fifth is a layout token that was wrong at every breakpoint, desktop included. - Contain vertical overscroll. Swipe mode scrolls the document itself, so the document scroller is the feed, and mobile browsers chained an overscroll at its top edge into pull-to-refresh — reloading the SPA and dropping the reader back at the first story. `contain` blocks the chain while keeping the local rubber-band that `none` would also remove. It sits on bare `html` rather than on swipe mode: testing on a phone found the profile route, which strips that class deliberately, reloading just as expensively. The cost is worth naming: an installed PWA has no address bar, so this gesture was the reader's only reload affordance and nothing replaces it. - Pair every hover affordance with a press state. Tailwind scopes `hover:` behind a `(hover: hover)` media query and its preflight zeroes the tap highlight, so a tap on a coarse pointer got no feedback at all. Reaching iOS took one more step: Safari applies `:active` only where a touch handler sits on the element or the document, and this app's only touchstart is on the swipe container — so the header, which mounts above the router, and every non-swipe route had no press feedback and no highlight left to fall back on. A passive no-op on the document is the whole fix. Dropdown items reach the same dead end from the other side: Radix guards its highlight behind `pointerType === 'mouse'`, so neither `hover:` nor `focus:` survives a touch press on the one menu that exists only where the nav is too narrow to hold its tabs. - Settle a committed swipe on a decelerating curve instead of `linear`, which arrived at full speed and stopped dead. Duration is budgeted against the curve's initial speed, so its first frame matches the finger rather than overshooting it, and the speed it inherits is measured over the last 80ms of the drag instead of averaged across the whole gesture. That average lost to the velocity floor on nearly every swipe, which left two gestures covering the same distance settling identically however they ended. A finger held still before lifting now reports a standstill rather than replaying its last burst of movement. - Guard the long-press selection UI, whose handles swallowed the drag: suppressed on chrome and collapsed at gesture lock, while story and comment prose stay selectable. Headlines are not, which testing on a phone settled: an Ask or Show post carries no URL, so its title renders as bare text and a long press raised the handles rather than a link callout. Content links do keep their callout, since those are arbitrary third-party URLs mid-thread and nothing else reaches them. - Derive `--header-height` from the header. Fixed swipe panels and the scroll indicator reserve space with this token, so when it under-reports the header paints over the top of every story — and the literal `53px` only ever described the header at a 16px default font size on a phone. At a 150% setting the header renders 79px. It is now `calc(3.25rem + 1px)`: the 2.25rem control row, the vertical padding, and the bottom border. The md/lg values come from Tailwind's variant directive rather than a hand-written px query, because the utilities they mirror compile to rem breakpoints that move with the reader's font size. Desktop had also been over-reserving by 8px, since only the base padding was ever encoded. Two sibling cleanups ride along. `.page-state-center-padded` is hand-written CSS standing in for a `max-w-6xl` utility container, and its gutters carried the same px-versus-rem mismatch. The theme toggle drops a `dark:hover:bg-muted` that was beating the ghost variant's `dark:hover:bg-muted/50` outright, since `cn()` is tailwind-merge and the button's own class lands last — leaving its dark hover opaque against a dark press at half that. Deleting it settles both on the variant's value. The body rule reserving room for the offline bar keeps its px query on purpose and now says why: it gates on which layout React mounted, which `useIsMobile` decides with `(max-width: 767px)`. Two new e2e specs hold all of it in place. `layout-tokens` measures both chrome tokens against the elements they describe, across four breakpoints at two font sizes and under emulated browser font settings. `touch-feel` pins the overscroll containment, including on the route that drops swipe mode, the selection collapse, and the iOS touch listener — each invisible in CI and only reproducible on hardware. The release-velocity estimator is unit tested directly, alongside a pair of gestures with identical displacement and different endings that fails against the old averaging. One existing spec stops asserting a literal 53px and 32px for padding these tokens already describe, and measures the chrome instead. Press states are the one surface no rendered test reaches, since a synthesised press leaves `:active` unset in every engine CI can drive, so a source-level check pairs each hover affordance with its `active:` twin. Every assertion was verified to fail against the mistake it exists to catch, not just to pass.
therealsama
force-pushed
the
feat/mobile-touch-feel
branch
from
September 2, 2026 04:45
f37041f to
4d30236
Compare
therealsama
enabled auto-merge
September 2, 2026 07:25
kplachkov
approved these changes
Sep 2, 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.
Summary
Five defects that each broke the illusion of a native feed on a phone. The first four are gesture and feedback gaps in mobile swipe mode; the fifth is a layout token that was wrong at every breakpoint, desktop included.
overscroll-behavior-y: containblocks the chain while keeping the rubber-bandnonewould also remove. It sits on barehtmlrather than scoped toswipe-mode, because/#/user/:idstrips that class and is just as expensive to reload.hover:inside@media (hover: hover)and its preflight zeroes-webkit-tap-highlight-color, so on a coarse pointer a tap gave no visual response at all. Every hover affordance that changes appearance has a matchingactive:state now, andenableTouchActiveStates()registers a passive documenttouchstartbecause iOS fires:activeonly where such a listener exists. One exclusion is deliberate: the active header tab, whose hover equals its base state.linear, arriving at full speed and halting. It ridescubic-bezier(0.2, 0.3, 0.45, 1)now, leaving the origin at the finger's release speed — measured over the last 80ms of the drag rather than averaged across the whole gesture — and its duration budget scales by the curve's initial slope, derived from the control points instead of restated beside them.useSwipeScrollis{ passive: true }, sopreventDefault()is unavailable and these two are the only levers.--header-heightwas the literal53px, and fixed panels plus the scroll indicator reserve space with it. That literal described the real header only at a 16px root font on a phone: at a 150% font setting the header renders 79px, so the token under-reserved by 26px and left the title's first line beneath it, while over-reserving by 8px on desktop. It iscalc(3.25rem + 1px)now — a 2.25rem control row, the vertical padding, and the 1px border — measured exact across 12 combinations of viewport and root font size.Worth a closer look
(any-pointer: coarse). The gesture is touch-only, so a mouse has no swipe to protect and keeps ordinary selection.any-rather thanpointer:orhover:deliberately: Gecko has reported the primary pointer asfineon touch-only Android phones (mozilla bug 1556983), which is the browser this was reported from, andany-covers a touch laptop besides..comment-contentopts back in, since copying a quote is native behaviour worth keeping. A text post's title has no link wrapping it, so a long press there raises the handles rather than the link callout — the exact failure the rest of this PR removes. Content links keep their-webkit-touch-callout, which on iOS is currently the only way to lift a URL out of the feed.@variant, not a hand-writtenmin-width.reminside a media query resolves against the browser's initial font size, so a px query would have flipped the token 384px early for a reader at 150% and reintroduced the drift at the boundary. The same mismatch is fixed in.page-state-center-padded. The one px query left is deliberate and now says so:body's offline-bar padding gates on which layout React mounted, anduseIsMobiledecides that with(max-width: 767px).hover:utility has anactive:twin with the same variants and property, because a synthesised press leaves:activeunset in every engine CI can drive.Trade-offs and open questions
ThemeToggle's dark hover is lighter than onmain. Its opaquedark:hover:bg-mutedwas dropped in favour of the ghost variant's/50, which is what the new press state matches.:hoverrules inindex.csssit outside the guard above and outside any(hover: hover)query, so a finger does reach them — as sticky hover rather than as a press.transition-colorsand fade over 150ms where the story row snaps. And whether the settle handoff reads as continuous needs an actual thumb; the 80ms window and the 1.2× boost are the numbers to try against if it feels off.Test plan
npm run typecheck,npm run lint,npm run buildnpm run test:run— 973 unit tests passnpm run e2e— 716 pass, 0 flaky, across Chromium, Firefox, Mobile Safari, and Mobile Chrome--repeat-each=3 --retries=0after fixing a mid-reflow race in one assertion