~ knotless Search/
↑↓ move↵ open⇧↵ all results

grain.social/grain

photography-focused photo sharing platform

grain.social
1 collaborator
0
2

next: scrolling, a fling's stop or a swipe opens no gallery, nor a photo's tap

Merged
Merged chadtmiller.com asked to merge into feature/hud from grain.social/grain:next/tap-guard

What changes

Scrolling opens no gallery. On next.grain.social, a click that ends a touch which moved more than 10 px, or that came down within 300 ms of the screen's scroller moving (a tap that stops a fling), opens nothing in a feed, a list or a profile's grid: not the card, nor its links or buttons. A mouse's clicks are as they were. HUD's renderer does this for every List and Covers (HUD fa60f26, web/renderer/src/view/taps.ts), so it takes no change to Grain's views.

A feed's photo opens nothing when tapped. A tap on a feed card's carousel no longer opens the gallery, as in Grain's own apps: on the web, GalleryCard opens the gallery from its title link alone and the photo only takes a double tap (favorite); in grain-ios, GalleryCardView's photo tap shows its alt text and nothing on the card pushes the gallery. The rest of the HUD card (header space, title, description, counts) still opens it, and a swipe still pages the carousel. HUDKit's carousel (ios/) takes its taps the same way.

Why

A feed card is one big link (the List item's <a class="open">), and its carousel passed its taps through to that link. Touch-emulated in Chromium (iPhone viewport, CDP touch events and a touch fling, against a release HUD and the built app) before this change:

  • A fling, then a tap to stop it, navigated in 5 of 5 tries: the browser fired a click on whatever had scrolled under the finger, sometimes a different card than the one pressed (pointerdown on one card's link, click on the next card's carousel).
  • A touch that moved 14 px still ended as a click and opened the gallery.
  • A tap on the photo opened the gallery through the carousel's tap-through.

Vertical drags and horizontal carousel swipes ended in pointercancel with no click, so those were not a cause on their own.

How it was checked

  • The same touch runs after it, against HUD fa60f26's renderer built here: a fling then a tap (5 positions) stays, a 14 px drag stays, a tap on the photo stays, a vertical drag and a carousel swipe stay. A clean tap on the card's title opens its gallery, an 8 px jitter still opens it, a tap 500 ms after a fling settles opens it, and a mouse click 17 ms after a wheel scroll opens it. On a profile, a clean tap on a cover opens it and a tap stopping a fling doesn't.
  • In HUD: svelte-check, the renderer's and shell's SSR tests (the renderer's with a new check of the tap rules on a hydrated card), HUDKit's tests on an iPhone 17 Pro simulator and Android hudkit's tests.
  • Here: node check-apps.mjs, npm run check, the unit tests and npm run build in next/. The iOS app was not built (HUDKit's own tests were run).

Shortcomings

  • Real phones weren't tried. Chromium's touch emulation reproduced the fling click, and iOS Safari and Chrome Android may differ in when they fire one.
  • A deliberate tap within 300 ms of the page scrolling (for any reason, a scroll anchoring jump included) is dropped and needs a second tap.
  • HUDKit gets no time guard: its items open on SwiftUI's onTapGesture inside a ScrollView, which UIKit's scroll view doesn't hand a touch that scrolls or stops its deceleration. That wasn't tried on a device or simulator. Only the carousel's tap changed there.

Review

Start at vendor/hud/web/renderer/src/view/taps.ts and tree/List.svelte.

Approved

This pull stops a tap that ends a drag, or that stops a fling, from opening a gallery on next.grain.social. It also makes a tap on a feed card's photo open nothing, as in Grain's own apps. I read all the changed files, which are the vendored HUD copy, the vendor/hud/COMMIT bump and the HUDKit carousel change. I found no bugs, so I'm approving.

  • taps.ts: The logic holds up. A mouse's clicks and a keyboard's (detail === 0) are left alone. A pointercancel marks the touch as moved. The walk up parentNode reaches the document, so a page's own scroll is caught.
  • Removing tapThrough: This is consistent with the CSS change. .content stays pointer-events: none except for [data-swipes], so a tap on the carousel now hits it rather than the item's link.
  • HUDKit: The empty onTapGesture on the carousel is plausible, but the pull says it was not tried on a device. When you next build ios/, check that a swipe still pages the carousel and that zoom still opens the lightbox.

The shortcomings the pull lists are accurate: it was not tried on a real phone, and a tap within 300 ms of any scroll is dropped. I'd check both on a phone before this reaches production.

The pull mentions a new renderer test of the tap rules, but this diff has no tests. That fits a vendored copy, since the tests live in HUD.

Thanks. On HUDKit: SwiftUI gives a child's tap gesture precedence over its ancestor's, so with zoom the picture's own onTapGesture still opens the lightbox, and the carousel's empty one only stops a tap reaching the List item's. A tap gesture never blocks the horizontal ScrollView's pan, so swipes still page. HUDKit's tests pass on an iPhone 17 Pro simulator, but neither was tried by hand: I'll leave that, and a real phone for the web side, to a check on a device before this reaches production, as you say. The new renderer test is HUD's (web/renderer/test/ssr.mjs, in fa60f26), not vendored here.

Merged as cc83f7b
Part of a stack of 2
  1. next: scrolling, a fling's stop or a swipe opens no gallery, nor a photo's tap Landed as cc83f7b
  2. main