Repository navigation
fix(player): a cancelled touch ends the seek drag, and the carousels and hooks get their first tests - #299
Conversation
The carousels' server render was covered, but nothing ran their effects: which slide Embla reports, which events they subscribe to, what a click asks of Embla, and whether the listeners leave on unmount. A stand-in for the Embla API (tests/_helpers/embla.ts) answers what each test sets, since jsdom lays nothing out and the real engine never scrolls there. ContentCarousel's reInit test fails with that subscription removed, so items that load after mount keep their arrows right. These tests come before extracting the shared wiring into one hook, and must hold across it. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjZcE8bs5uRJ6dsg6kw
…wiring ColumnCarousel and ContentCarousel each spelled out the same Embla setup: the centred one-at-a-time options, three scroll callbacks, and an effect that reads the position once the API exists and again on every event. hooks/useCarousel.ts now owns that, and each carousel passes only the option it adds (startIndex, inViewThreshold) and reads the state it draws. The hook keeps ContentCarousel's reInit subscription, so items that load after mount still re-read the arrows and the in-view slides. ColumnCarousel now hears reInit and slidesInView too: the first re-reads the selected column when the slides change, the second costs a re-render while scrolling and nothing else. The interaction tests from the previous commit pass unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjZcE8bs5uRJ6dsg6kw
The progress handle listened for touchend and mouseup but not touchcancel, which the browser sends when the system takes a touch back mid-gesture. The drag then stayed on: the window kept its non-passive touchmove listener, so the next touch anywhere on the page called preventDefault and could not scroll, and it moved the handle and the video frame to wherever that finger went, seeking there on its touchend. A cancelled touch now ends the drag and drops the previewed position, so the handle returns to the playing time. Nothing was released, so nothing is seeked. These are the hook's first tests: mouse and touch drags, the seek on release, the hand-over to the player's time, and the wraparound guard at the top of the ring. The touchcancel test fails without the fix (the drag stays on, a later touchmove is prevented and moves the handle). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjZcE8bs5uRJ6dsg6kw
EmbedButton's copy feedback rests on this hook, and nothing ran it: the write and its result, the copied flag's timeout, the restart on a second copy, the refused write and the missing Clipboard API, and the timer an unmount must clear. Removing either clearTimeout fails a test. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjZcE8bs5uRJ6dsg6kw
This hook puts the locale's strings on every route, error page included, and passToClient serialises what it returns into the page. Nothing ran it. The tests pin the two reads it hands pageContext to, that the preview token never reaches the result (handing back the session itself fails them), and the English, no-preview fallback when either read throws. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjZcE8bs5uRJ6dsg6kw
embla-carousel-react returns `undefined` until the viewport ref attaches
and its own effect creates the API. The stand-in returned an API on the
first render, so the carousel tests never reached useCarousel's
`if (!emblaApi) return` guard: removing it left all 37 carousel tests
green while both carousels would throw in a browser.
The stand-in now waits for the ref to attach and creates the API in an
effect, as the real hook does. With the guard removed, all 15 carousel
interaction tests fail; with ContentCarousel's `ref={emblaRef}` removed,
6 fail.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjZcE8bs5uRJ6dsg6kw
Embla's scrollTo takes a snap index, and `trimSnaps` puts every slide that fits at the start of the row on snap 0. ColumnCarousel's full-width slides each get a snap of their own, so its dots are right. ContentCarousel passes a clicked slide's index, which overshoots once a wide viewport merges leading slides. That predates the hook (main's ContentCarousel set trimSnaps too), so it is marked as a shortcut here rather than changed in a test bundle; the test names the one-snap-per-slide assumption it relies on. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjZcE8bs5uRJ6dsg6kw
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
wemeditate-design | b770b6f | Commit Preview URL Branch Preview URL |
Nov 19 2026, 10:55 PM |
A review asked whether any of this wiring could be dropped in favour of Embla's built-in handling. `align`, `slidesToScroll` and `containScroll` are the only lines that can: all three are Embla 8.6.0's own defaults. They stay because both carousels read them as part of their contract -- `align: 'center'` is ColumnCarousel's centre start, and `trimSnaps` is the snap-vs-slide hazard the hook's doc comment owns -- and a default is the maintainer's to change in a major. Say so at the site, so the next reader does not have to ask again. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjVdrFdreoK86VEaswY
|
Addressed the Embla thread, left open for you to settle. Dropped what can be. Kept the rest, with evidence. Updating gains nothing. 8.6.0 is the latest stable and what the lockfile resolves. 9.0.0 has been in RC since January, with renamed methods, options and events.
🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
wemeditate-web | b770b6f | Commit Preview URL Branch Preview URL |
Nov 19 2026, 10:55 PM |
Summary
preventDefaultcalled on it, so the page could not be scrolled by touch, and the handle jumped to wherever the finger landed. Now a cancelled touch ends the drag and returns the handle to the playing time, without seeking.ColumnCarouselandContentCarouselnow share onehooks/useCarousel.tsfor their Embla wiring, where each used to carry its own copy. Interaction tests pinned both carousels before the refactor, and the same tests pass after it.useCircularProgress,useClipboardandpages/+onBeforeRender.tsget their first tests.Findings addressed
components/molecules/ColumnCarousel/ColumnCarousel.interaction.test.tsx(7 tests) andcomponents/molecules/blocks/ContentCarousel/ContentCarousel.interaction.test.tsx(8 tests). jsdom does no layout, sotests/_helpers/embla.tsstands in for the Embla API and reports whatever position each test sets. The stand-in hands the API out the same wayembla-carousel-react8.6.0 does:undefineduntil the viewport ref attaches, then the API, created in an effect (review fix, below). With main's two carousel files checked out under these tests, all of them pass. Removing'reInit'from the hook's events fails exactly "re-reads the arrows when the slides change".hooks/useCarousel.tsholds the shared options (align: 'center',slidesToScroll: 1,containScroll: 'trimSnaps'), the three scroll callbacks, and one effect that re-reads position onselect,slidesInViewandreInit(hooks/useCarousel.ts:43-60). ColumnCarousel passes onlystartIndex, and ContentCarousel passes onlyinViewThreshold. ContentCarousel keeps itsreInithandling. ColumnCarousel now also listens forreInit, which re-reads the selected column when the slides change. Both stories were checked in Ladle with the real Embla at 390px: dots, nav titles, end-of-row disabling, withdrawn arrows and dimmed slides all behave as before. The existing SSR tests (ColumnCarousel.test.tsx,ContentCarousel.test.tsx,RelatedContent.test.tsx,tests/guards/faded-controls.test.ts) pass unchanged. Changing the initialselectedIndexto 0 fails 4 SSR tests.useCircularProgress, and the touchcancel bug. The bug was real. Fixed by atouchcancellistener incomponents/organisms/MeditationPlayer/useCircularProgress.ts:116-125, which clears the previewed position and ends the drag. The hook lives undercomponents/organisms/MeditationPlayer/, nothooks/. New fileuseCircularProgress.test.ts(6 tests, jsdom) covers: a mouse drag that previews and then seeks once on release, a seek target that holds untilcurrentTimecatches up, a touch drag that callspreventDefaultand seeks ontouchend, and the wraparound guard at the top in both directions. On main, "ends the drag on a cancelled touch, without seeking" fails withexpected true to be false. A probe run on main also showeddisplayTimeat 450 instead of 20 after the cancel, and a latertouchmovemoving the handle to 150.useClipboard. New filehooks/useClipboard.test.ts(6 tests, jsdom, fake timers) covers the write and itstrueresult, the copied flag with the default and a custom timeout, the timer restarting on a second copy, a refused write and a missing Clipboard API both returningfalse, and no timer left behind after unmount. Removing eitherclearTimeout(hooks/useClipboard.ts:43,:58) fails a test. No production change.pages/+onBeforeRender.ts. Re-verified that main had no test for it. New filepages/onBeforeRender.test.ts(no+prefix, perdocs/rules/testing.md), 4 tests. It mocksloadTranslationsandloadLivePreviewbut keeps the realtoClientStateandLIVE_PREVIEW_OFF. It pins that both reads receive the pageContext, that the translations and the client preview state come back, that the preview token never reaches the serialised result, and that the result falls back toEN_TRANSLATIONSwith no preview when either read throws. Returning the session instead oftoClientState(session)(pages/+onBeforeRender.ts:37) fails 2 tests. No production change.if (!emblaApi) returnguard (hooks/useCarousel.ts:44). With that guard removed, all 37 carousel tests used to pass, although both carousels would throw aTypeErrorin a browser. Now the same mutation fails all 15 carousel interaction tests. Removing ContentCarousel'sref={emblaRef}now fails 6 of them.align: 'center',slidesToScroll: 1andcontainScroll: 'trimSnaps'are Embla 8.6.0's own defaults. They stay as a deliberate pin, andhooks/useCarousel.tsnow says so at the site. Nothing else drops.embla-carousel-reactexports one hook,useEmblaCarousel, returning[ref, api | undefined]and no state of its own (node_modules/embla-carousel-react/index.d.ts), so the subscription effect is the whole React binding; every getter it reads —selectedScrollSnap,slidesInView,canScrollPrev,canScrollNext— is already a built-in. Deriving ColumnCarousel's nav bounds fromcanScrollPrev/canScrollNextinstead of the column count fails 7 tests, because the server render has no Embla to ask.embla-carousel-class-nameswould move ContentCarousel's dimming to anis-in-viewclass, but the click-to-scroll on a dimmed slide reads the same flag, so the React state stays and the plugin only adds parts. Updating gains nothing either: 8.6.0 (April 2025) is the latest stable and is what the lockfile resolves; 9.0.0 has been in release candidates since January 2026 (rc04, October 2026), with renamed methods, options and events.scrollTotakes a snap index, andtrimSnapsputs every slide that fits at the start of the row on snap 0. The hook'sscrollToparameter is now namedsnap, and its doc comment says which indexes are snaps and which are slides. ContentCarousel's click-to-scroll passes a slide index, so it now carries ashortcut:line (ContentCarousel.tsx:190-192). The interaction test states the one-snap-per-slide assumption behind itsscrollTo(2)assertion. ColumnCarousel's full-width slides each get their own snap, so its dots are unaffected.Not in this PR
trimSnaps). Fixing it means mapping the slide throughemblaApi.internalEngine().slideRegistry, as Embla's ownSlideFocusdoes, and checking the result in a browser at a wide viewport. That is a behaviour change, so it is left for a follow-up and marked in the code with ashortcut:line.useAudioPlayer) belong to the forms, a11y and audio bundles.sahajcloud-context,_lecture.ts,_meditation.ts) belong to other bundles or open PRs.Reconciled with open PRs
None of the open PRs touches any file this PR changes. Each branch's diff was checked against
ColumnCarousel*,ContentCarousel*,hooks/useCarousel.ts,useCircularProgress*,useClipboard*,onBeforeRender*andtests/_helpers/embla.ts.MeditationPlayer.tsxand the audio hooks. Its keyboard seek bypassesuseCircularProgress, and it leaves the hook alone, so the touchcancel fix stays inside the hook.MeditationPlayer.tsxandVideoPlayer. This PR edits neither.ContentCardandLayoutBlock, not ContentCarousel.package.jsonanddocs/rules/testing.md. This PR adds no dependency and leaves the testing rule alone.tests/guards/but no helper undertests/_helpers/.Test results
Results from
.claude/skills/pr-prep/check.shon the pushed head:mainmerge, not with this branch.tsc --noEmit: passed.vitest run: 136 files, 1306 of 1306 tests passed.pnpm build: not run, because this bundle is not marked BUILD.mainwas merged into the branch atad54db0, cleanly and with no conflict, so the gate above ran on the merged tree.🤖 Generated with Claude Code
https://claude.ai/code/session_01Mg9rjZcE8bs5uRJ6dsg6kw