diff --git a/client/src/mobile/components/MDayPager.test.tsx b/client/src/mobile/components/MDayPager.test.tsx new file mode 100644 index 000000000..60b064a6e --- /dev/null +++ b/client/src/mobile/components/MDayPager.test.tsx @@ -0,0 +1,167 @@ +import { act, fireEvent, render, screen } from '@testing-library/react'; +import { beforeEach, describe, expect, it, vi } from 'vitest'; +import { tickHaptic } from '../../native/haptics'; +import type { Day } from '../../types'; +import MDayPager, { pagesFor } from './MDayPager'; + +vi.mock('../../native/haptics', () => ({ tickHaptic: vi.fn() })); + +const DAYS = [{ id: 1 }, { id: 2 }, { id: 3 }, { id: 4 }] as unknown as Day[]; + +function setup(selectedDayId: number | null, over: Partial[0]> = {}) { + const onSelectDay = vi.fn(); + const utils = render( + `day ${i + 1} of ${n}`} + renderDay={(dayId, active) =>

{`page ${dayId ?? 'none'}${active ? ' live' : ''}`}

} + {...over} + /> + ); + const strip = utils.container.querySelector('[data-day-pager]') as HTMLElement; + return { ...utils, strip, onSelectDay }; +} + +/** jsdom has no layout: say where each page sits, with `restingId` filling the strip. */ +function place(strip: HTMLElement, restingId: number | null, between = false) { + strip.getBoundingClientRect = () => ({ left: 0 }) as DOMRect; + for (const page of Array.from(strip.children) as HTMLElement[]) { + const here = page.dataset.dayId === String(restingId); + page.getBoundingClientRect = () => ({ left: here ? (between ? 37 : 0) : 400 }) as DOMRect; + } +} + +beforeEach(() => { + vi.mocked(tickHaptic).mockReset(); +}); + +describe('pagesFor', () => { + it('windows the selection with its neighbours', () => { + expect(pagesFor(DAYS, 2).map((p) => [p.dayId, p.active])).toEqual([ + [1, false], + [2, true], + [3, false], + ]); + }); + + it('has no page beyond the first and last day', () => { + expect(pagesFor(DAYS, 1).map((p) => p.dayId)).toEqual([1, 2]); + expect(pagesFor(DAYS, 4).map((p) => p.dayId)).toEqual([3, 4]); + }); + + it('keeps a page for a selection that points at no day, with the first day as the way back', () => { + expect(pagesFor(DAYS, null).map((p) => [p.key, p.dayId, p.active])).toEqual([ + ['none', null, true], + ['d1', 1, false], + ]); + expect(pagesFor([], null).map((p) => p.key)).toEqual(['none']); + }); +}); + +describe('MDayPager', () => { + it('draws the current day live and its neighbours inert', () => { + const { strip } = setup(2); + + expect(screen.getByText('page 2 live')).toBeInTheDocument(); + const pages = Array.from(strip.children) as HTMLElement[]; + expect(pages.map((p) => p.hasAttribute('inert'))).toEqual([true, false, true]); + expect(pages[0]).toHaveAttribute('aria-hidden', 'true'); + expect(pages[1]).not.toHaveAttribute('aria-hidden'); + }); + + it('selects the neighbour the strip comes to rest on, with a detent and an announcement', () => { + const { strip, onSelectDay } = setup(2); + + place(strip, 3); + fireEvent(strip, new Event('scrollend')); + + expect(onSelectDay).toHaveBeenCalledWith(3); + expect(tickHaptic).toHaveBeenCalledTimes(1); + expect(screen.getByRole('status')).toHaveTextContent('day 3 of 4'); + }); + + it('asks once, however many events report the same landing', () => { + const { strip, onSelectDay } = setup(2); + + place(strip, 1); + fireEvent(strip, new Event('scrollend')); + fireEvent(strip, new Event('scrollend')); + + expect(onSelectDay).toHaveBeenCalledTimes(1); + }); + + it('does nothing when it comes back to the current day or is still between pages', () => { + const { strip, onSelectDay } = setup(2); + + place(strip, 2); + fireEvent(strip, new Event('scrollend')); + place(strip, 3, true); + fireEvent(strip, new Event('scrollend')); + + expect(onSelectDay).not.toHaveBeenCalled(); + }); + + it('waits for the finger to lift where scrollend is missing', () => { + vi.useFakeTimers(); + try { + const { strip, onSelectDay } = setup(2); + place(strip, 3); + + fireEvent.touchStart(strip); + fireEvent.scroll(strip); + act(() => { + vi.advanceTimersByTime(200); + }); + expect(onSelectDay).not.toHaveBeenCalled(); + + fireEvent.touchEnd(strip); + act(() => { + vi.advanceTimersByTime(200); + }); + expect(onSelectDay).toHaveBeenCalledWith(3); + } finally { + vi.useRealTimers(); + } + }); + + it('puts the strip back on the current page when the window moves', () => { + const { strip, rerender, onSelectDay } = setup(2); + // jsdom keeps no scroll offset, so give the strip one to move. + let scrollLeft = 0; + Object.defineProperty(strip, 'scrollLeft', { + configurable: true, + get: () => scrollLeft, + set: (v) => { + scrollLeft = v; + }, + }); + // After the selection moves to day 3, its page sits one page width to the right. + const realQuery = strip.querySelector.bind(strip); + vi.spyOn(strip, 'querySelector').mockImplementation((sel: string) => { + const el = realQuery(sel) as HTMLElement | null; + if (el && sel === '[data-page-active]') el.getBoundingClientRect = () => ({ left: 390 }) as DOMRect; + return el; + }); + strip.getBoundingClientRect = () => ({ left: 0 }) as DOMRect; + + rerender( + ''} + renderDay={(dayId) =>

{`page ${dayId}`}

} + /> + ); + + expect(strip.scrollLeft).toBe(390); + }); + + it('holds still while locked', () => { + const { strip } = setup(2, { locked: true }); + expect(strip).toHaveClass('overflow-x-hidden'); + expect(strip).not.toHaveClass('overflow-x-auto'); + }); +}); diff --git a/client/src/mobile/components/MDayPager.tsx b/client/src/mobile/components/MDayPager.tsx new file mode 100644 index 000000000..fc0fffc5b --- /dev/null +++ b/client/src/mobile/components/MDayPager.tsx @@ -0,0 +1,197 @@ +import type { ReactNode } from 'react'; +import { useCallback, useEffect, useLayoutEffect, useRef, useState } from 'react'; +import { tickHaptic } from '../../native/haptics'; +import type { Day } from '../../types'; + +/** + * Pages through the trip's days the way a native pager does: the previous, + * current and next day sit side by side in a horizontal scroll-snap strip, so + * the finger drags real paper, the neighbour slides in with it, and the + * browser's compositor owns the gesture. Momentum, rubber-banding at the first + * and last day, axis locking against the vertical scroll and the swallowed tap + * after a swipe are all the platform's own, in the PWA and the app alike. + * + * The day only changes once the strip has come to rest on a neighbour. Then + * the selection moves, the window of three shifts by one and the strip is put + * back on the centre page before the next paint, so nothing visibly jumps. + * Keys follow the day ids, so the page that slid in keeps its state (scroll + * position, fetched route and weather) as it becomes the current one. + * + * RTL needs nothing of its own: under dir="rtl" the strip lays out right to + * left, which puts the next day on the left, and every offset here is read off + * bounding rects rather than scrollLeft, whose sign flips in RTL. + */ + +/** Fallback settle delay where `scrollend` is missing (Safari before 26). */ +const SETTLE_MS = 90; +/** How close to a page edge counts as resting on it. */ +const REST_PX = 2; + +export interface MDayPagerProps { + days: Day[]; + selectedDayId: number | null; + onSelectDay: (dayId: number) => void; + /** Draws one day. Pages other than the current one are inert and hidden + * from assistive tech, so they never take focus or a tap. */ + renderDay: (dayId: number | null, active: boolean) => ReactNode; + /** Holds the strip still: a reorder drag or an open menu owns the finger. */ + locked?: boolean; + /** Live-region text after a swipe lands on a day. */ + describeDay: (index: number, total: number) => string; +} + +interface Page { + key: string; + dayId: number | null; + active: boolean; +} + +/** The window of pages around the selection. A selection that points at no + * day (the whole-trip view, or a day deleted remotely) still gets its page, + * with the first day next to it as a way back. */ +export function pagesFor(days: Day[], selectedDayId: number | null): Page[] { + const i = days.findIndex((d) => d.id === selectedDayId); + if (i < 0) { + const first = days[0]; + return [ + { key: 'none', dayId: selectedDayId, active: true }, + ...(first ? [{ key: `d${first.id}`, dayId: first.id, active: false }] : []), + ]; + } + const pages: Page[] = []; + const prev = days[i - 1]; + const next = days[i + 1]; + if (prev) pages.push({ key: `d${prev.id}`, dayId: prev.id, active: false }); + pages.push({ key: `d${days[i].id}`, dayId: days[i].id, active: true }); + if (next) pages.push({ key: `d${next.id}`, dayId: next.id, active: false }); + return pages; +} + +export default function MDayPager({ + days, + selectedDayId, + onSelectDay, + renderDay, + locked = false, + describeDay, +}: MDayPagerProps) { + const stripRef = useRef(null); + const [announcement, setAnnouncement] = useState(''); + const pages = pagesFor(days, selectedDayId); + const windowKey = pages.map((p) => p.key).join(','); + + // The handlers below are attached once, so they read the props through here. + const latest = useRef({ days, onSelectDay, describeDay, selectedDayId }); + latest.current = { days, onSelectDay, describeDay, selectedDayId }; + /** The day a landed swipe asked for, until the selection catches up. Stops a + * late scroll event from selecting it twice. */ + const requested = useRef(null); + + /** Puts the strip back on the current page, instantly. */ + const recentre = useCallback(() => { + const strip = stripRef.current; + const current = strip?.querySelector('[data-page-active]'); + if (!strip || !current) return; + const offset = current.getBoundingClientRect().left - strip.getBoundingClientRect().left; + if (Math.abs(offset) > 0.5) strip.scrollLeft += offset; + }, []); + + // Before paint whenever the window moves: a landed swipe or a chip tap. + useLayoutEffect(() => { + requested.current = null; + recentre(); + }, [windowKey, recentre]); + + // Rotation and split view change the page width; keep the current page whole. + useEffect(() => { + const strip = stripRef.current; + if (!strip || typeof ResizeObserver === 'undefined') return; + const observer = new ResizeObserver(() => recentre()); + observer.observe(strip); + return () => observer.disconnect(); + }, [recentre]); + + useEffect(() => { + const strip = stripRef.current; + if (!strip) return; + let timer = 0; + let touching = false; + + const settle = () => { + if (touching) return; + const left = strip.getBoundingClientRect().left; + let resting: HTMLElement | null = null; + for (const child of Array.from(strip.children) as HTMLElement[]) { + if (Math.abs(child.getBoundingClientRect().left - left) <= REST_PX) resting = child; + } + // Still between pages: the snap has not finished, another event follows. + if (!resting || resting.hasAttribute('data-page-active')) return; + const raw = resting.dataset.dayId; + const dayId = raw ? Number(raw) : NaN; + if (!Number.isFinite(dayId) || requested.current === dayId) return; + requested.current = dayId; + const s = latest.current; + tickHaptic(); + s.onSelectDay(dayId); + const index = s.days.findIndex((d) => d.id === dayId); + if (index >= 0) setAnnouncement(s.describeDay(index, s.days.length)); + }; + const later = () => { + window.clearTimeout(timer); + timer = window.setTimeout(settle, SETTLE_MS); + }; + const onScrollEnd = () => { + window.clearTimeout(timer); + settle(); + }; + const onTouchStart = () => { + touching = true; + }; + const onTouchEnd = () => { + touching = false; + later(); + }; + + strip.addEventListener('scroll', later, { passive: true }); + strip.addEventListener('scrollend', onScrollEnd); + strip.addEventListener('touchstart', onTouchStart, { passive: true }); + strip.addEventListener('touchend', onTouchEnd, { passive: true }); + strip.addEventListener('touchcancel', onTouchEnd, { passive: true }); + return () => { + window.clearTimeout(timer); + strip.removeEventListener('scroll', later); + strip.removeEventListener('scrollend', onScrollEnd); + strip.removeEventListener('touchstart', onTouchStart); + strip.removeEventListener('touchend', onTouchEnd); + strip.removeEventListener('touchcancel', onTouchEnd); + }; + }, []); + + return ( + <> + {/* Swipe-landed days only. A chip tap already speaks its own label plus + the aria-current flip, so announcing there would say the day twice. */} + + {announcement} + +
+ {pages.map((page) => ( +
+ {renderDay(page.dayId, page.active)} +
+ ))} +
+ + ); +} diff --git a/client/src/mobile/screens/trip/plan/MPlanTimeline.tsx b/client/src/mobile/screens/trip/plan/MPlanTimeline.tsx index 3db3587c2..a038bf930 100644 --- a/client/src/mobile/screens/trip/plan/MPlanTimeline.tsx +++ b/client/src/mobile/screens/trip/plan/MPlanTimeline.tsx @@ -1,4 +1,4 @@ -import { useRef, useState, type MouseEvent } from 'react' +import { useEffect, useState, type MouseEvent } from 'react' import { ArrowRight, BedDouble, CalendarDays, CalendarRange, ChevronRight, Compass, LogIn, LogOut, MapPin, Pencil, PencilLine, Route, Ticket, TrainFront, Undo2 } from 'lucide-react' import type { LucideIcon } from 'lucide-react' import { useContextMenu, ContextMenu } from '../../../../components/shared/ContextMenu' @@ -24,8 +24,7 @@ import type { RouteSegment } from '../../../../types' import type { Assignment } from '../../../../types' import type { ComponentType, ReactNode } from 'react' import GoogleMapsIcon from '../../../../components/shared/GoogleMapsIcon' -import { isRtlLanguage } from '../../../../i18n' -import { useMPlanDaySwipe } from './useMPlanDaySwipe' +import MDayPager from '../../../components/MDayPager' /** * Plan-tab timeline of the mobile trip screen: the UP-NEXT card in go mode, @@ -37,13 +36,74 @@ import { useMPlanDaySwipe } from './useMPlanDaySwipe' const GLASS_PILL = 'rounded-full border border-[color:var(--m-gbr)] bg-[color:var(--m-glass)]' export default function MPlanTimeline({ planner, shell }: MPlanTimelineProps) { - const tl = useMPlanTimeline(planner) + const { t, trip, can } = planner + const editing = shell.mode === 'edit' && can('day_edit', trip) + // Per-segment travel mode (#1281): one menu for the whole pager, opened from + // whichever day is current. + const legMenu = useContextMenu() + // Plugin time contributions in the day plan (dayScheduleProvider hook) — + // slotted under their anchor rows, same as the desktop sidebar. + const daySchedule = usePluginDaySchedule(planner.tripId) + // Long-press drag reordering (#1997). Armed only in edit mode, so go-mode taps, + // map pans and plain list scrolling keep the gesture — which is what kept + // #1432/#1440 from coming back when the old document-wide polyfill was dropped. + // Coarse pointers only: a hybrid laptop narrow enough to land in the phone + // shell already loads drag-drop-touch (utils/touchDragPolyfill), and two + // bridges would fight over one gesture. The rows' native drag props serve + // both, so nothing is lost there. One bridge for the pager: it listens on + // the document, and only the current day arms its rows. + const isTouch = useIsTouch() + useTouchDragBridge(editing && isTouch) + const [dragging, setDragging] = useState(false) + + return ( +
+ + {/* Swipe the days like pages (#2051): the one-handed way to the next day, + since the chip rail is pinned to the top of the screen. */} + planner.handleSelectDay(dayId, true)} + locked={dragging || legMenu.menu != null} + describeDay={(i, n) => t('mobileTrip.dayAnnounce', { current: i + 1, total: n })} + renderDay={(dayId, active) => ( + + )} + /> +
+ ) +} + +/** + * One day of the timeline: the UP-NEXT card or the edit header, and the frosted + * card. The pager draws the current day and its two neighbours with this; only + * the current one is live, the others are inert previews of the same markup so + * the page that slides in is exactly what lands. + */ +function PlanDayPage({ planner, shell, dayId: pageDayId, active, editing, legMenu, daySchedule, onDragging }: MPlanTimelineProps & { + dayId: number | null + active: boolean + editing: boolean + legMenu: ReturnType + daySchedule: ReturnType + onDragging?: (dragging: boolean) => void +}) { + const tl = useMPlanTimeline(planner, pageDayId) const { t, trip, can } = planner const canEdit = can('day_edit', trip) - const editing = shell.mode === 'edit' && canEdit const canEditPlaces = can('place_edit', trip) - // Per-segment travel mode (#1281): tap a connector → pick the leg's mode. - const legMenu = useContextMenu() const openLegMenu = (e: MouseEvent, assignmentId: number, seg: RouteSegment) => { // Public transit sits under the road profiles, as on the desktop (#2398). const transitLeg = tl.transitLegFor(seg) @@ -54,9 +114,6 @@ export default function MPlanTimeline({ planner, shell }: MPlanTimelineProps) { transitLeg ? () => tl.planTransitLeg(transitLeg, assignmentId) : undefined, )) } - // Plugin time contributions in the day plan (dayScheduleProvider hook) — - // slotted under their anchor rows, same as the desktop sidebar. - const daySchedule = usePluginDaySchedule(planner.tripId) const day = tl.day const dayId = day?.id // A stay chip opens the stay, the same way the stay card in the day sheet @@ -90,39 +147,14 @@ export default function MPlanTimeline({ planner, shell }: MPlanTimelineProps) { planner.handlePlaceClick(assignment.place?.id ?? null, assignment.id) } - // Long-press drag reordering (#1997). Armed only in edit mode, so go-mode taps, - // map pans and plain list scrolling keep the gesture — which is what kept - // #1432/#1440 from coming back when the old document-wide polyfill was dropped. - // Coarse pointers only: a hybrid laptop narrow enough to land in the phone - // shell already loads drag-drop-touch (utils/touchDragPolyfill), and two - // bridges would fight over one gesture. The rows' native drag props serve - // both, so nothing is lost there. - const isTouch = useIsTouch() - useTouchDragBridge(editing && isTouch) const dnd = useMPlanDragReorder({ merged: tl.merged, dayId, onMove: tl.moveRowTo, - enabled: editing, - }) - // Swipe the whole panel left/right to step days (#2051) — the one-handed way - // to the next day, since the chip rail is pinned to the top of the screen. - const panelRef = useRef(null) - const cardRef = useRef(null) - const daySwipe = useMPlanDaySwipe({ - days: planner.days, - selectedDayId: planner.selectedDayId, - // skipFit, exactly like the chip tap in plan view: the map underneath stays - // mounted, and re-framing it here would move it somewhere nobody asked for. - onSelectDay: dayId => planner.handleSelectDay(dayId, true), - panelRef, - cardRef, - editing, - dragging: dnd.draggingKey != null, - menuOpen: legMenu.menu != null, - rtl: isRtlLanguage(planner.language), - describeDay: (i, n) => t('mobileTrip.dayAnnounce', { current: i + 1, total: n }), + enabled: editing && active, }) + const draggingNow = dnd.draggingKey != null + useEffect(() => { onDragging?.(draggingNow) }, [onDragging, draggingNow]) const dragFor = (row: PlanRow): RowDrag | undefined => { const props = dnd.dragPropsFor(row) @@ -146,12 +178,7 @@ export default function MPlanTimeline({ planner, shell }: MPlanTimelineProps) { const chrome = { editing, t, language: tl.language, timeFormat: tl.timeFormat } return ( -
- - {/* Swipe-committed day changes only — a chip tap already speaks its own - button label plus the aria-current flip, so announcing there would say - the day twice. */} - {daySwipe.announcement} +
{!editing && } {editing && } @@ -159,9 +186,8 @@ export default function MPlanTimeline({ planner, shell }: MPlanTimelineProps) { collapses that reserved space up to the day chips when the day has no up-next (no places), so an empty day shows no gap. */}
{planner.toursEnabled && tl.rows.some(row => row.kind === 'place' && row.invalidTour) && ( @@ -446,10 +472,10 @@ function TimelineHeader({ tl, dayLabel, openLabel, weatherLabel, onOpenDay, onOp const WeatherIcon = weatherIconFor(tl.weather?.main) return (
- {/* The one horizontal scroller inside the swipe zone, marked so a swipe - that starts here is handed back to it — but only while it really - overflows, so a short day title still swipes. */} - + {/* The one horizontal scroller inside the day pager. Nested scrolling is + the browser's: while the chips overflow they pan first, and the pager + takes over at their end or when they fit. */} + -
-
- ) -} - -/** Feeds the committed day straight back in, the way the planner does — the only - * way to show a burst of swipes stepping day by day rather than repeating one. */ -function StatefulHarness() { - const [dayId, setDayId] = useState(11) - return { onSelectDay(id); setDayId(id) }} /> -} - -const panel = () => screen.getByTestId('panel') -const card = () => screen.getByTestId('card') -const live = () => screen.getByTestId('live') - -function mount(props: Partial = {}) { - return prepare(render()) -} - -function mountStateful() { - return prepare(render()) -} - -function prepare(view: T): T { - const el = card() - Object.defineProperty(el, 'scrollTop', { get: () => scroll.top, configurable: true }) - Object.defineProperty(el, 'scrollLeft', { get: () => scroll.left, configurable: true }) - // jsdom has no Element.prototype.scrollTo, which is why the hook calls it - // optionally — the spy is what lets the reset be asserted at all. - el.scrollTo = vi.fn() - return view -} - -function overflow(el: HTMLElement, scrollWidth: number, clientWidth: number) { - Object.defineProperty(el, 'scrollWidth', { value: scrollWidth, configurable: true }) - Object.defineProperty(el, 'clientWidth', { value: clientWidth, configurable: true }) -} - -interface Point { x: number; y?: number; dt?: number } - -/** Plays a touch path. The first point is the press, the rest are moves; the - * press itself is never a move, so a path of one point is a plain tap. */ -function drag(target: HTMLElement, path: Point[]): Point { - const [start, ...moves] = path - fireEvent.touchStart(target, { touches: [{ clientX: start.x, clientY: start.y ?? 300 }] }) - let last = start - for (const p of moves) { - if (p.dt) act(() => { vi.advanceTimersByTime(p.dt!) }) - fireEvent.touchMove(target, { touches: [{ clientX: p.x, clientY: p.y ?? 300 }] }) - last = p - } - return last -} - -function release(target: HTMLElement, at: Point) { - fireEvent.touchEnd(target, { touches: [], changedTouches: [{ clientX: at.x, clientY: at.y ?? 300 }] }) -} - -/** Runs both animation legs plus the spring, so the DOM lands in its rest state. */ -function settle() { - act(() => { vi.advanceTimersByTime(600) }) -} - -/** A committing left swipe: 100px, fast enough to be a flick as well. */ -function swipeLeft(target = panel(), from = 300) { - const last = drag(target, [{ x: from }, { x: from + 3 }, { x: from - 20, dt: 30 }, { x: from - 100, dt: 30 }]) - release(target, last) - settle() -} - -function swipeRight(target = panel(), from = 300) { - const last = drag(target, [{ x: from }, { x: from - 3 }, { x: from + 20, dt: 30 }, { x: from + 100, dt: 30 }]) - release(target, last) - settle() -} - -beforeEach(() => { - onSelectDay.mockClear() - onRowClick.mockClear() - scroll.top = 0 - scroll.left = 0 - vi.useFakeTimers() - // Both animation legs hang off rAF; running it inline keeps the timers the - // only clock the tests have to drive. - vi.stubGlobal('requestAnimationFrame', (cb: FrameRequestCallback) => { cb(0); return 0 }) -}) - -afterEach(() => { - vi.useRealTimers() - vi.unstubAllGlobals() - document.documentElement.removeAttribute('data-reduce-motion') -}) - -describe('useMPlanDaySwipe', () => { - describe('committing', () => { - it('FE-MOB-DAYSWIPE-001: a swipe left steps to the next day', () => { - mount() - swipeLeft() - expect(onSelectDay).toHaveBeenCalledTimes(1) - expect(onSelectDay).toHaveBeenCalledWith(13) - }) - - it('FE-MOB-DAYSWIPE-002: a swipe right steps to the previous day', () => { - mount() - swipeRight() - expect(onSelectDay).toHaveBeenCalledWith(11) - }) - - it('FE-MOB-DAYSWIPE-003: a short, slow drag springs back to rest', () => { - mount() - const last = drag(panel(), [{ x: 300 }, { x: 303 }, { x: 280, dt: 300 }, { x: 270, dt: 300 }]) - release(panel(), last) - expect(onSelectDay).not.toHaveBeenCalled() - settle() - expect(panel().style.transform).toBe('') - expect(panel().style.transition).toBe('') - }) - - it('FE-MOB-DAYSWIPE-004: a flick commits short of the distance threshold', () => { - mount() - const last = drag(panel(), [{ x: 300 }, { x: 303 }, { x: 288, dt: 15 }, { x: 270, dt: 15 }]) - release(panel(), last) - settle() - expect(onSelectDay).toHaveBeenCalledWith(13) - }) - - it('FE-MOB-DAYSWIPE-005: a fast but tiny move is not a flick', () => { - mount() - const last = drag(panel(), [{ x: 300 }, { x: 303 }, { x: 288, dt: 10 }, { x: 280, dt: 10 }]) - release(panel(), last) - settle() - expect(onSelectDay).not.toHaveBeenCalled() - }) - }) - - describe('yielding to the gestures that were already there', () => { - it('FE-MOB-DAYSWIPE-006: a vertical drag never touches the panel', () => { - mount() - const last = drag(panel(), [{ x: 300 }, { x: 302, y: 320, dt: 20 }, { x: 304, y: 420, dt: 20 }]) - expect(panel().style.transform).toBe('') - release(panel(), last) - settle() - expect(onSelectDay).not.toHaveBeenCalled() - }) - - it('FE-MOB-DAYSWIPE-007: a diagonal drag inside the bias goes to the scroller', () => { - mount() - const last = drag(panel(), [{ x: 300 }, { x: 340, y: 338, dt: 20 }, { x: 400, y: 400, dt: 20 }]) - release(panel(), last) - settle() - expect(onSelectDay).not.toHaveBeenCalled() - }) - - it('FE-MOB-DAYSWIPE-008: a card that has already scrolled vertically kills the gesture', () => { - mount() - fireEvent.touchStart(panel(), { touches: [{ clientX: 300, clientY: 300 }] }) - scroll.top = 12 - fireEvent.touchMove(panel(), { touches: [{ clientX: 180, clientY: 300 }] }) - release(panel(), { x: 180 }) - settle() - expect(onSelectDay).not.toHaveBeenCalled() - expect(panel().style.transform).toBe('') - }) - - it('FE-MOB-DAYSWIPE-009: a card that has already scrolled sideways kills it too', () => { - mount() - fireEvent.touchStart(panel(), { touches: [{ clientX: 300, clientY: 300 }] }) - scroll.left = 9 - fireEvent.touchMove(panel(), { touches: [{ clientX: 180, clientY: 300 }] }) - release(panel(), { x: 180 }) - settle() - expect(onSelectDay).not.toHaveBeenCalled() - }) - - it('FE-MOB-DAYSWIPE-017: a swipe started on an overflowing horizontal strip is handed back', () => { - mount() - const strip = screen.getByTestId('strip') - overflow(strip, 300, 200) - const last = drag(strip, [{ x: 300 }, { x: 280, dt: 30 }, { x: 200, dt: 30 }]) - release(strip, last) - settle() - expect(onSelectDay).not.toHaveBeenCalled() - }) - - it('FE-MOB-DAYSWIPE-018: the same strip swipes normally while it fits', () => { - mount() - const strip = screen.getByTestId('strip') - overflow(strip, 200, 200) - const last = drag(strip, [{ x: 300 }, { x: 280, dt: 30 }, { x: 200, dt: 30 }]) - release(strip, last) - settle() - expect(onSelectDay).toHaveBeenCalledWith(13) - }) - - it('FE-MOB-DAYSWIPE-019: no touch event is ever cancelled or stopped', () => { - mount() - const seen: { type: string; prevented: boolean }[] = [] - const spy = (e: Event) => seen.push({ type: e.type, prevented: e.defaultPrevented }) - for (const type of ['touchstart', 'touchmove', 'touchend']) document.addEventListener(type, spy) - try { - swipeLeft() - } finally { - for (const type of ['touchstart', 'touchmove', 'touchend']) document.removeEventListener(type, spy) - } - // Reaching document at all proves propagation was never stopped; the drag - // bridge's own 10px self-cancel depends on both halves of this. - expect(seen.map(s => s.type)).toContain('touchstart') - expect(seen.map(s => s.type)).toContain('touchmove') - expect(seen.map(s => s.type)).toContain('touchend') - expect(seen.every(s => !s.prevented)).toBe(true) - }) - }) - - describe('refusing to arm', () => { - it('FE-MOB-DAYSWIPE-010: the last day resists instead of wrapping', () => { - mount({ selectedDayId: 13 }) - const last = drag(panel(), [{ x: 300 }, { x: 280, dt: 20 }, { x: 100, dt: 20 }]) - const pulled = Math.abs(parseFloat(panel().style.transform.replace(/[^-\d.]/g, ''))) - expect(pulled).toBeLessThanOrEqual(48) - release(panel(), last) - settle() - expect(onSelectDay).not.toHaveBeenCalled() - }) - - it('FE-MOB-DAYSWIPE-011: the first day resists the other way', () => { - mount({ selectedDayId: 11 }) - swipeRight() - expect(onSelectDay).not.toHaveBeenCalled() - }) - - it('FE-MOB-DAYSWIPE-012: a single-day trip never arms', () => { - mount({ days: [DAYS[0]], selectedDayId: 11 }) - swipeLeft() - expect(onSelectDay).not.toHaveBeenCalled() - expect(panel().style.transform).toBe('') - }) - - it('FE-MOB-DAYSWIPE-013: a two-finger touch never arms', () => { - mount() - fireEvent.touchStart(panel(), { touches: [{ clientX: 300, clientY: 300 }, { clientX: 340, clientY: 300 }] }) - fireEvent.touchMove(panel(), { touches: [{ clientX: 180, clientY: 300 }] }) - release(panel(), { x: 180 }) - settle() - expect(onSelectDay).not.toHaveBeenCalled() - }) - - it('FE-MOB-DAYSWIPE-014: a row already being dragged owns the finger', () => { - mount({ dragging: true }) - swipeLeft() - expect(onSelectDay).not.toHaveBeenCalled() - }) - - it('FE-MOB-DAYSWIPE-015: an open leg menu owns the finger', () => { - mount({ menuOpen: true }) - swipeLeft() - expect(onSelectDay).not.toHaveBeenCalled() - }) - - it('FE-MOB-DAYSWIPE-016: the screen edges are left to the browser', () => { - mount() - swipeLeft(panel(), 8) - expect(onSelectDay).not.toHaveBeenCalled() - swipeRight(panel(), window.innerWidth - 8) - expect(onSelectDay).not.toHaveBeenCalled() - }) - }) - - describe('edit mode', () => { - it('FE-MOB-DAYSWIPE-028: a press held past the drag window stops being a swipe', () => { - mount({ editing: true }) - fireEvent.touchStart(panel(), { touches: [{ clientX: 300, clientY: 300 }] }) - act(() => { vi.advanceTimersByTime(400) }) - fireEvent.touchMove(panel(), { touches: [{ clientX: 180, clientY: 300 }] }) - release(panel(), { x: 180 }) - settle() - expect(onSelectDay).not.toHaveBeenCalled() - }) - - it('FE-MOB-DAYSWIPE-029: go mode has no drag bridge, so a slow swipe still counts', () => { - mount({ editing: false }) - fireEvent.touchStart(panel(), { touches: [{ clientX: 300, clientY: 300 }] }) - act(() => { vi.advanceTimersByTime(400) }) - fireEvent.touchMove(panel(), { touches: [{ clientX: 180, clientY: 300 }] }) - release(panel(), { x: 180 }) - settle() - expect(onSelectDay).toHaveBeenCalledWith(13) - }) - }) - - describe('right to left', () => { - it('FE-MOB-DAYSWIPE-020: an RTL locale mirrors both directions', () => { - mount({ rtl: true }) - swipeLeft() - expect(onSelectDay).toHaveBeenCalledWith(11) - onSelectDay.mockClear() - swipeRight() - expect(onSelectDay).toHaveBeenCalledWith(13) - }) - }) - - describe('taps and clicks', () => { - it('FE-MOB-DAYSWIPE-021: the click a swipe leaves behind never reaches a row', () => { - mount() - swipeLeft() - fireEvent.click(screen.getByTestId('row')) - expect(onRowClick).not.toHaveBeenCalled() - }) - - it('FE-MOB-DAYSWIPE-022: only that one click is swallowed', () => { - mount() - swipeLeft() - fireEvent.click(screen.getByTestId('row')) - fireEvent.click(screen.getByTestId('row')) - expect(onRowClick).toHaveBeenCalledTimes(1) - }) - - it('FE-MOB-DAYSWIPE-023: a plain tap opens its row, and a stray touchend does not throw', () => { - mount() - release(panel(), { x: 300 }) - drag(panel(), [{ x: 300 }]) - release(panel(), { x: 300 }) - fireEvent.click(screen.getByTestId('row')) - expect(onRowClick).toHaveBeenCalledTimes(1) - }) - - it('FE-MOB-DAYSWIPE-024: a cancelled gesture springs back and changes nothing', () => { - mount() - drag(panel(), [{ x: 300 }, { x: 280, dt: 20 }, { x: 200, dt: 20 }]) - fireEvent.touchCancel(panel(), { touches: [], changedTouches: [{ clientX: 200, clientY: 300 }] }) - settle() - expect(onSelectDay).not.toHaveBeenCalled() - expect(panel().style.transform).toBe('') - }) - }) - - describe('after the day changes', () => { - it('FE-MOB-DAYSWIPE-025: the new day starts at the top of the card', () => { - mount() - swipeLeft() - expect(card().scrollTo).toHaveBeenCalledWith({ top: 0 }) - }) - - it('FE-MOB-DAYSWIPE-026: the live region names the day that was reached', () => { - mount() - swipeLeft() - expect(live()).toHaveTextContent('dayAnnounce:3,3') - }) - - it('FE-MOB-DAYSWIPE-027: mounting announces nothing', () => { - mount() - expect(live()).toHaveTextContent('') - }) - }) - - describe('reduced motion', () => { - it('FE-MOB-DAYSWIPE-030: the day still changes, the panel just never moves', () => { - document.documentElement.setAttribute('data-reduce-motion', '') - mount() - const last = drag(panel(), [{ x: 300 }, { x: 303 }, { x: 280, dt: 30 }, { x: 200, dt: 30 }]) - expect(panel().style.transform).toBe('') - release(panel(), last) - settle() - expect(onSelectDay).toHaveBeenCalledWith(13) - expect(live()).toHaveTextContent('dayAnnounce:3,3') - expect(panel().style.transform).toBe('') - }) - }) - - describe('interruption', () => { - it('FE-MOB-DAYSWIPE-031: a burst of swipes steps day by day, and unmounting mid-animation is quiet', () => { - const stateful = mountStateful() - // The second swipe starts before the first one's out-leg has landed, so - // the interrupt has to commit day 1 → 2 before day 2 → 3 can resolve. - const first = drag(panel(), [{ x: 300 }, { x: 303 }, { x: 280, dt: 30 }, { x: 200, dt: 30 }]) - release(panel(), first) - const second = drag(panel(), [{ x: 300 }, { x: 303 }, { x: 280, dt: 30 }, { x: 200, dt: 30 }]) - release(panel(), second) - settle() - expect(onSelectDay.mock.calls.map(c => c[0])).toEqual([12, 13]) - stateful.unmount() - - onSelectDay.mockClear() - const view = mount() - const third = drag(panel(), [{ x: 300 }, { x: 303 }, { x: 280, dt: 30 }, { x: 200, dt: 30 }]) - release(panel(), third) - view.unmount() - act(() => { vi.advanceTimersByTime(600) }) - expect(onSelectDay).not.toHaveBeenCalled() - }) - }) -}) diff --git a/client/src/mobile/screens/trip/plan/useMPlanDaySwipe.ts b/client/src/mobile/screens/trip/plan/useMPlanDaySwipe.ts deleted file mode 100644 index ceea2097c..000000000 --- a/client/src/mobile/screens/trip/plan/useMPlanDaySwipe.ts +++ /dev/null @@ -1,379 +0,0 @@ -import { useCallback, useEffect, useRef, useState } from 'react' -import { flushSync } from 'react-dom' -import type { MouseEvent as ReactMouseEvent, RefObject, TouchEvent as ReactTouchEvent } from 'react' -import type { Day } from '../../../../types' - -/** - * Swipe the mobile day panel left/right to step through the trip's days (#2051). - * - * The phone shell puts the days on a chip rail pinned to the top of the screen, - * which on a large phone is a thin target a thumb cannot reach one-handed. The - * day details fill the rest of the screen and did nothing, so this hands that - * whole surface the same job the rail has. - * - * The gesture is purely observational: it never calls preventDefault and never - * stops propagation on a touch event, and it sets no touch-action. Two reasons. - * The browser keeps sole ownership of the card's vertical scroll, so the worst a - * misread can do is translate the panel and spring it back. And the long-press - * reorder bridge (utils/touchDragBridge) listens on `document`, below React's - * root — swallowing a touchmove would starve its own 10px self-cancel and leave - * it arming a drag on a row the finger had already left. - */ - -/** Movement before the gesture is classified. Same figure as SystemNoticeModal. */ -const CLASSIFY_PX = 8 -/** |dx| must beat |dy| by this to claim horizontal. Scrolling is the gesture - * this card already had, so it wins the ties. */ -const AXIS_BIAS = 1.2 -/** Travel that commits on release. */ -const COMMIT_PX = 56 -/** A flick commits short of COMMIT_PX. 0.5 px/ms sits under MSheet's 0.6 dismiss - * — turning a page is a smaller motion than throwing a sheet off screen. */ -const FLICK_V = 0.5 -const FLICK_MIN_PX = 24 -/** Velocity is measured over the trailing window, not the last frame: the final - * move before lift is often a pixel or two and reads as a standstill. */ -const SAMPLE_MS = 100 -/** Rubber band: 1:1 up to FREE, then heavy, then a hard stop. */ -const RUBBER_FREE_PX = 72 -const RUBBER_FACTOR = 0.35 -const RUBBER_MAX_PX = 132 -/** On the first and last day there is nowhere to go, so the pull is far stiffer. */ -const EDGE_FACTOR = 0.18 -const EDGE_MAX_PX = 48 -/** iOS' interactive back/forward strip cannot be turned off, only avoided. The - * card's own left edge is at 16px, so this costs its outermost 8px as a start. */ -const EDGE_GUTTER_PX = 24 -/** Kept in step with touchDragBridge's LONG_PRESS_MS. Past this window the press - * belongs to the reorder drag. Edit mode only — go mode never installs the - * bridge, so a leisurely one-handed swipe still counts there. */ -const PRESS_WINDOW_MS = 320 -const OUT_MS = 150 -const IN_MS = 220 -const REDUCED_MS = 120 -/** Percent of the panel width the outgoing / incoming day travels. */ -const OUT_OFFSET = 22 -const IN_OFFSET = 14 -const EASE = 'var(--ease-drawer)' -const SPRING = 'cubic-bezier(0.34,1.56,0.64,1)' - -type Lock = null | 'h' | 'dead' - -interface Gesture { - x0: number - y0: number - t0: number - scrollTop0: number - scrollLeft0: number - lock: Lock - samples: { x: number; t: number }[] -} - -function applyX(el: HTMLElement | null, px: string | null): void { - if (!el) return - el.style.transform = px == null ? '' : `translateX(${px})` -} - -function band(dx: number, free: number, factor: number, max: number): number { - const a = Math.abs(dx) - return Math.sign(dx) * Math.min(a <= free ? a : free + (a - free) * factor, max) -} - -/** - * Which way this finger is going, once it has moved far enough to tell. - * `null` means it has not, so the caller waits for the next move. - */ -function classifyLock( - g: Gesture, - dx: number, - dy: number, - now: number, - card: HTMLElement | null, - s: { dragging: boolean; editing: boolean }, -): Lock { - // The browser has already committed this gesture to scrolling, so obey it. - // scrollLeft counts too: overflow-y-auto on its own leaves overflow-x - // computing to auto, and a wide markdown table in a day note fills it. - if (card && (card.scrollTop !== g.scrollTop0 || card.scrollLeft !== g.scrollLeft0)) return 'dead' - if (Math.abs(dx) <= CLASSIFY_PX && Math.abs(dy) <= CLASSIFY_PX) return null - // Edit mode only: past the bridge's press window this finger belongs to a - // reorder drag. Go mode has no bridge, so a slow swipe still counts. - if (s.dragging || (s.editing && now - g.t0 > PRESS_WINDOW_MS)) return 'dead' - return Math.abs(dx) >= Math.abs(dy) * AXIS_BIAS ? 'h' : 'dead' -} - -/** The media query plus the app's own appearance toggle, which writes the same - * attribute PluginFrame reads. */ -function reducedMotion(): boolean { - if (typeof window === 'undefined') return false - if (document.documentElement.dataset.reduceMotion !== undefined) return true - return window.matchMedia?.('(prefers-reduced-motion: reduce)')?.matches ?? false -} - -export interface MPlanDaySwipeArgs { - days: Day[] - selectedDayId: number | null - /** Always called with skipFit — see the call site in MPlanTimeline for why. */ - onSelectDay: (dayId: number) => void - /** The element that gets translated: MPlanTimeline's `absolute inset-0` root. */ - panelRef: RefObject - /** The frosted timeline card. Its scroll offsets are how we ask the browser - * whether it has already claimed the gesture. */ - cardRef: RefObject - /** Edit mode: the long-press reorder bridge is installed and competes. */ - editing: boolean - /** True once the bridge has armed and fired its dragstart. */ - dragging: boolean - /** True while the per-leg travel-mode menu is open. */ - menuOpen: boolean - /** Flips next/prev, same rule the notice pager uses. */ - rtl: boolean - /** Live-region text for a committed swipe. */ - describeDay: (index: number, total: number) => string -} - -export interface MPlanDaySwipe { - /** Announced to screen readers after a swipe commits — empty until then. */ - announcement: string - handlers: { - onTouchStart: (e: ReactTouchEvent) => void - onTouchMove: (e: ReactTouchEvent) => void - onTouchEnd: (e: ReactTouchEvent) => void - onTouchCancel: () => void - onClickCapture: (e: ReactMouseEvent) => void - } -} - -export function useMPlanDaySwipe({ - days, selectedDayId, onSelectDay, panelRef, cardRef, - editing, dragging, menuOpen, rtl, describeDay, -}: MPlanDaySwipeArgs): MPlanDaySwipe { - const gesture = useRef(null) - const swallowClick = useRef(false) - /** The one scheduled animation step. Never more than one is outstanding. */ - const pending = useRef<{ timer: number; run: () => void } | null>(null) - const alive = useRef(true) - const [announcement, setAnnouncement] = useState('') - - // The handlers are stable callbacks reading per-render values, so a ref mirror - // keeps them current. `dragging` in particular has to be read this way: the - // reorder hook's setDraggingKey runs inside the dragstart the bridge fires, so - // a render-scoped read lags by a commit — exactly the window we bail in. - const latest = useRef({ days, selectedDayId, onSelectDay, editing, dragging, menuOpen, rtl, describeDay }) - latest.current = { days, selectedDayId, onSelectDay, editing, dragging, menuOpen, rtl, describeDay } - - const cancelPending = useCallback(() => { - const p = pending.current - pending.current = null - if (p) window.clearTimeout(p.timer) - }, []) - - /** Terminal state: byte-identical to the idle DOM. Never queues another step — - * a settle that re-enters the queue is what makes a spring-back recurse. */ - const settle = useCallback(() => { - // A live drag owns the panel: a stale timer left over from the previous - // animation must not wipe the transform out from under the finger. - if (gesture.current?.lock === 'h') return - const el = panelRef.current - if (!el) return - el.style.transition = '' - el.style.transform = '' - }, [panelRef]) - - const schedule = useCallback((ms: number, run: () => void) => { - cancelPending() - const timer = window.setTimeout(() => { pending.current = null; run() }, ms) - pending.current = { timer, run } - }, [cancelPending]) - - /** Runs the outstanding step now. Interruption only — never on unmount, where - * it would land in a tree that is already tearing down. */ - const finishPending = useCallback(() => { - const p = pending.current - pending.current = null - if (!p) return - window.clearTimeout(p.timer) - p.run() - }, []) - - /** Resolved at release from the live days array, by index — never from an index - * captured at touchstart, and never day_number ± 1: day_number is optional and - * a delete leaves gaps. */ - const targetFor = useCallback((dx: number): number | null => { - const s = latest.current - // Finger to the left means forward in LTR; RTL mirrors it. - const step = (dx < 0) === !s.rtl ? 1 : -1 - const i = s.days.findIndex(d => d.id === s.selectedDayId) - // Dangling selection: a remote day:deleted drops the day but leaves - // selectedDayId pointing at it, which shows a blank timeline. A swipe is a - // cheap way back out of that. - if (i < 0) return s.days[0]?.id ?? null - return s.days[i + step]?.id ?? null - }, []) - - /** Commits the day and parks the panel where the incoming leg starts. */ - const handoff = useCallback((dayId: number, fromPct: number | null) => { - if (!alive.current) return - const el = panelRef.current - if (el && fromPct != null) { - el.style.transition = 'none' - applyX(el, `${fromPct}%`) - } - const s = latest.current - const idx = s.days.findIndex(d => d.id === dayId) - const apply = () => { - s.onSelectDay(dayId) - if (idx >= 0) setAnnouncement(s.describeDay(idx, s.days.length)) - } - // Flushed so the new day is in the DOM before the incoming leg is armed in - // the same frame; otherwise one frame paints the old day off-centre. - if (fromPct == null) apply() - else flushSync(apply) - // The new day starts at the top. - cardRef.current?.scrollTo?.({ top: 0 }) - - if (!el || fromPct == null) { settle(); return } - requestAnimationFrame(() => { - if (!alive.current) return - el.style.transition = `transform ${IN_MS}ms ${EASE}` - applyX(el, '0px') - // transitionend does not fire in a backgrounded tab, under a display:none - // ancestor, or in jsdom. The timer is both the production net and what the - // tests drive. - schedule(IN_MS + 40, settle) - }) - }, [cardRef, panelRef, schedule, settle]) - - const commit = useCallback((dx: number): boolean => { - const target = targetFor(dx) - if (target == null) return false - const el = panelRef.current - - if (!el || reducedMotion()) { - handoff(target, null) - // Gentler, not zero — the same call mobile.css makes for its own reduced - // path. The fade goes on the card, never on the panel: an ancestor with - // opacity < 1 becomes a backdrop root and cancels the card's own blur. - const card = cardRef.current - if (card) { - card.style.transition = 'none' - card.style.opacity = '0' - requestAnimationFrame(() => { - if (!alive.current) return - card.style.transition = `opacity ${REDUCED_MS}ms ease-out` - card.style.opacity = '' - window.setTimeout(() => { card.style.transition = '' }, REDUCED_MS + 20) - }) - } - return true - } - - const forward = dx < 0 - el.style.transition = `transform ${OUT_MS}ms ease-out` - applyX(el, `${forward ? -OUT_OFFSET : OUT_OFFSET}%`) - schedule(OUT_MS, () => handoff(target, forward ? IN_OFFSET : -IN_OFFSET)) - return true - }, [cardRef, handoff, panelRef, schedule, targetFor]) - - const springBack = useCallback(() => { - const el = panelRef.current - if (!el) return - if (reducedMotion()) { settle(); return } - el.style.transition = `transform 300ms ${SPRING}` - applyX(el, '0px') - schedule(340, settle) - }, [panelRef, schedule, settle]) - - const onTouchStart = useCallback((e: ReactTouchEvent) => { - // Interruption lands the outstanding commit rather than dropping it, so - // three swipes in a burst move three days. - finishPending() - swallowClick.current = false - gesture.current = null - const s = latest.current - if (e.touches.length !== 1) return - if (s.days.length < 2 || s.dragging || s.menuOpen) return - const touch = e.touches[0] - if (touch.clientX < EDGE_GUTTER_PX || touch.clientX > window.innerWidth - EDGE_GUTTER_PX) return - // The header chip strip owns its own pan, but only while it really overflows - // — a short day title with no hotel chips still swipes. - const strip = (e.target as Element | null)?.closest?.('[data-hswipe-ignore]') - if (strip && strip.scrollWidth > strip.clientWidth + 1) return - const now = Date.now() - gesture.current = { - x0: touch.clientX, y0: touch.clientY, t0: now, - scrollTop0: cardRef.current?.scrollTop ?? 0, - scrollLeft0: cardRef.current?.scrollLeft ?? 0, - lock: null, - samples: [{ x: touch.clientX, t: now }], - } - }, [cardRef, finishPending]) - - const onTouchMove = useCallback((e: ReactTouchEvent) => { - const g = gesture.current - if (!g || g.lock === 'dead' || e.touches.length !== 1) return - const touch = e.touches[0] - const now = Date.now() - const dx = touch.clientX - g.x0 - const dy = touch.clientY - g.y0 - g.samples.push({ x: touch.clientX, t: now }) - while (g.samples.length > 2 && now - g.samples[0].t > SAMPLE_MS) g.samples.shift() - - if (g.lock === null) { - g.lock = classifyLock(g, dx, dy, now, cardRef.current, latest.current) - if (g.lock !== 'h') return - } - - if (reducedMotion()) return // classify and commit, but never follow the finger - const el = panelRef.current - if (!el) return - el.style.transition = 'none' - applyX(el, `${targetFor(dx) == null - ? band(dx, 0, EDGE_FACTOR, EDGE_MAX_PX) - : band(dx, RUBBER_FREE_PX, RUBBER_FACTOR, RUBBER_MAX_PX)}px`) - }, [cardRef, panelRef, targetFor]) - - const onTouchEnd = useCallback((e: ReactTouchEvent) => { - const g = gesture.current - gesture.current = null - if (!g || g.lock !== 'h') return - // The finger travelled far enough sideways to be a swipe rather than a tap, - // so the click the browser may still send is not one the rows should see. - swallowClick.current = true - const dx = (e.changedTouches[0]?.clientX ?? g.x0) - g.x0 - const first = g.samples[0] - const last = g.samples[g.samples.length - 1] - const v = (last.x - first.x) / Math.max(1, last.t - first.t) - const far = Math.abs(dx) > COMMIT_PX - const flick = Math.abs(v) > FLICK_V && Math.abs(dx) > FLICK_MIN_PX && Math.sign(v) === Math.sign(dx) - if ((far || flick) && commit(dx)) return - springBack() - }, [commit, springBack]) - - const onTouchCancel = useCallback(() => { - const g = gesture.current - gesture.current = null - if (g?.lock === 'h') springBack() - }, [springBack]) - - /** Root-scoped on purpose, unlike the drag bridge's one-shot document listener: - * that one eats an innocent click 400ms later whenever the expected click never - * arrives, and it would also swallow the document click the leg menu closes on. - * The flag is cleared on every fresh touchstart, so it cannot go stale. */ - const onClickCapture = useCallback((e: ReactMouseEvent) => { - if (!swallowClick.current) return - swallowClick.current = false - e.preventDefault() - e.stopPropagation() - }, []) - - useEffect(() => { - alive.current = true - return () => { alive.current = false; cancelPending() } - }, [cancelPending]) - - return { - announcement, - handlers: { onTouchStart, onTouchMove, onTouchEnd, onTouchCancel, onClickCapture }, - } -} diff --git a/client/src/mobile/screens/trip/plan/useMPlanTimeline.ts b/client/src/mobile/screens/trip/plan/useMPlanTimeline.ts index 92ea3ee91..45a4aad42 100644 --- a/client/src/mobile/screens/trip/plan/useMPlanTimeline.ts +++ b/client/src/mobile/screens/trip/plan/useMPlanTimeline.ts @@ -33,11 +33,15 @@ const placeIdsOf = (items: Assignment[]): number[] => * remove/edit place, the add bars, optimize and the Google-Maps export. * Reads tripStore directly only for dayNotes, which the planner doesn't expose. */ -export function useMPlanTimeline(planner: TripPlanner) { +export function useMPlanTimeline(planner: TripPlanner, forDayId?: number | null) { const { - tripId, days, assignments, reservations, tripAccommodations, selectedDayId, + tripId, days, assignments, reservations, tripAccommodations, t, language, settings, toast, tripActions, pushUndo, updateRouteForDay, routeProfile, } = planner + // The day pager draws the neighbours of the selected day too, each through its + // own instance of this hook, so the day is a parameter. Left out, it is the + // planner's selection. + const selectedDayId = forDayId === undefined ? planner.selectedDayId : forDayId const dayNotes = useTripStore(s => s.dayNotes) const day = days.find(d => d.id === selectedDayId) diff --git a/client/src/mobile/screens/trip/roadtrip/MRoadtripTab.tsx b/client/src/mobile/screens/trip/roadtrip/MRoadtripTab.tsx index e4b869aa4..f925cc5ea 100644 --- a/client/src/mobile/screens/trip/roadtrip/MRoadtripTab.tsx +++ b/client/src/mobile/screens/trip/roadtrip/MRoadtripTab.tsx @@ -1,6 +1,6 @@ -import { Fragment, useCallback, useMemo, useRef } from 'react' +import { Fragment, useCallback, useMemo } from 'react' import { AlertTriangle, MapPin, Navigation } from 'lucide-react' -import { useMPlanDaySwipe } from '../plan/useMPlanDaySwipe' +import MDayPager from '../../../components/MDayPager' import { showStopOnMap, useMRoadtrip } from './useMRoadtrip' import { useMRtCorridor } from './useMRtCorridor' import { useMRtAlternatives } from './useMRtAlternatives' @@ -15,7 +15,6 @@ import { navigationTargetLabel, getNavigationTargets } from '../../../../compone import { useSettingsStore } from '../../../../store/settingsStore' import { formatDistance } from '../../../../utils/units' import { formatClockTime } from '../../../../utils/formatters' -import { isRtlLanguage } from '../../../../i18n' import type { MTripTabPanelProps } from '../MTripShell' import { arrivingReroutable, legReroutable, type StopRow } from '../../../../components/Roadtrip/roadtripRowModel' import { ARRIVING_DRIVE, type RailDrive } from '../../../../components/Roadtrip/useRouteAlternatives' @@ -41,8 +40,6 @@ import type { Reservation, TranslationFn } from '../../../../types' */ export default function MRoadtripTab({ planner, shell }: MTripTabPanelProps) { const { t, days } = planner - const panelRef = useRef(null) - const cardRef = useRef(null) const rt = useMRoadtrip(planner) const corridor = useMRtCorridor(planner, shell) // Called once here and handed down, like `rt`: the chain's leg buttons and the bar over @@ -52,33 +49,97 @@ export default function MRoadtripTab({ planner, shell }: MTripTabPanelProps) { const is12h = useSettingsStore(s => s.settings.time_format) === '12h' const chrome: RowChrome = { t, unit, is12h } - // The same gesture the day timeline uses, called rather than rebuilt: 370 lines of - // worked-out conflict avoidance, down to the dead 24px gutter that stops iOS from - // reading a swipe as its own back gesture. - const daySwipe = useMPlanDaySwipe({ - days, - selectedDayId: planner.selectedDayId, - // skipFit: the map underneath stays mounted, and the stage's own focus points - // frame it as soon as the selection moves. - onSelectDay: dayId => planner.handleSelectDay(dayId, true), - panelRef, - cardRef, - editing: false, - dragging: false, - menuOpen: !!shell.sheet, - rtl: isRtlLanguage(planner.language), - describeDay: (i, n) => t('mobileTrip.dayAnnounce', { current: i + 1, total: n }), - }) - const stage = rt.stage + // The search bar sits in the same band on both halves, at the same offset, so the + // list/map switch never moves it: it is one stage seen two ways, and a control that + // jumps between them is a control you have to find twice. The band and the margins + // are the plan tab's POI bar, for the same reason. + // + // Only over a stage. Without one there is no drive to search along: the corridor would + // fall back to the trip's first routed day, which is not the one on screen, and every + // distance it answered with would be measured against a road nobody is looking at. + const searchBar = stage && ( +
+ shell.openSheet('rtsearch')} /> +
+ ) + + // ── Map half: the search bar, and the picker's bar while it is open. Everything + // between them belongs to the map instance the shell keeps mounted, so this layer must + // not swallow taps. + // + // A stage bar used to stand over the dock whenever the map was up: the day's + // destination with its picture, its stop count, its arrival and its distance. It went + // because the day and the distance are already in the shell's stage header, and on a + // map that fills the screen a permanent card over the bottom edge costs more than the + // three facts it added. + // + // While other ways of driving a leg are on offer, their bar stands in that now empty + // slot and the search bar steps away. The picker is modal on the map: its lines are the + // question on screen, a corridor search started under it would draw its pins over + // them, and the band it frees at the top is room the leg is framed into. + if (shell.rtView === 'map') { + return ( +
+ {!alts.open && searchBar} + {/* Just above the dock, the same gap everything else on this shell keeps from it. + Mounted only while the picker is open, so nothing invisible lies over the map's + own buttons the rest of the time. */} + {alts.open && ( +
+ +
+ )} +
+ ) + } + + // ── List half ──────────────────────────────────────────────────────────────── + // The stages page like the plan tab's days (#2051): the day pager draws the stage on + // either side as well, so a swipe drags the next one in. The search bar stays put over + // the strip, because the corridor it searches is the selected stage's. + return ( +
+ planner.handleSelectDay(dayId, true)} + locked={!!shell.sheet} + describeDay={(i, n) => t('mobileTrip.dayAnnounce', { current: i + 1, total: n })} + renderDay={dayId => ( + + )} + /> + {searchBar} +
+ ) +} + +/** + * One stage of the list half, as the day pager draws it: the selected stage and the + * ones either side. Each page reads its own stage, so the one that slides in is + * exactly the one that lands. + */ +function RoadtripStagePage({ planner, shell, dayId: pageDayId, alts, chrome }: MTripTabPanelProps & { + dayId: number | null + alts: ReturnType + chrome: RowChrome +}) { + const { t } = planner + const rt = useMRoadtrip(planner, pageDayId) + const stage = rt.stage + const { unit, is12h } = chrome + // The map's whole-trip view leaves no day selected, and it stays that way when the // list comes up: the switch here restores nothing on purpose, and the plan tab's // toggle does that job only for its own timeline. The chain is one stage wide, so // with routed days and no day picked it asks for one, rather than claiming there is // no route while the header above prints the whole drive's distance. A day that is // picked and has no drive of its own still gets the empty stage further down. - const noDayPicked = !stage && !rt.empty && !rt.loading && planner.selectedDayId == null + const noDayPicked = !stage && !rt.empty && !rt.loading && pageDayId == null // The disc is only a control for somebody who may change a place. Read here rather than // inside the row so the whole chain asks once, the way `rt` and `chrome` are handled. @@ -133,61 +194,13 @@ export default function MRoadtripTab({ planner, shell }: MTripTabPanelProps) { else planner.handlePlaceClick(reading.placeId) } - // The search bar sits in the same band on both halves, at the same offset, so the - // list/map switch never moves it: it is one stage seen two ways, and a control that - // jumps between them is a control you have to find twice. The band and the margins - // are the plan tab's POI bar, for the same reason. - // - // Only over a stage. Without one there is no drive to search along: the corridor would - // fall back to the trip's first routed day, which is not the one on screen, and every - // distance it answered with would be measured against a road nobody is looking at. - const searchBar = stage && ( -
- shell.openSheet('rtsearch')} /> -
- ) - - // ── Map half: the search bar, and the picker's bar while it is open. Everything - // between them belongs to the map instance the shell keeps mounted, so this layer must - // not swallow taps. - // - // A stage bar used to stand over the dock whenever the map was up: the day's - // destination with its picture, its stop count, its arrival and its distance. It went - // because the day and the distance are already in the shell's stage header, and on a - // map that fills the screen a permanent card over the bottom edge costs more than the - // three facts it added. - // - // While other ways of driving a leg are on offer, their bar stands in that now empty - // slot and the search bar steps away. The picker is modal on the map: its lines are the - // question on screen, a corridor search started under it would draw its pins over - // them, and the band it frees at the top is room the leg is framed into. - if (shell.rtView === 'map') { - return ( -
- {!alts.open && searchBar} - {/* Just above the dock, the same gap everything else on this shell keeps from it. - Mounted only while the picker is open, so nothing invisible lies over the map's - own buttons the rest of the time. */} - {alts.open && ( -
- -
- )} -
- ) - } - - // ── List half ──────────────────────────────────────────────────────────────── + // Room for the search bar, which only stands over a stage. return ( -
- {daySwipe.announcement} - {searchBar} -
+
{noDayPicked ? ( @@ -360,7 +373,6 @@ export default function MRoadtripTab({ planner, shell }: MTripTabPanelProps) { )} -
) } diff --git a/client/src/mobile/screens/trip/roadtrip/useMRoadtrip.ts b/client/src/mobile/screens/trip/roadtrip/useMRoadtrip.ts index 15ffc792b..cfdab81d9 100644 --- a/client/src/mobile/screens/trip/roadtrip/useMRoadtrip.ts +++ b/client/src/mobile/screens/trip/roadtrip/useMRoadtrip.ts @@ -43,8 +43,11 @@ export interface MRoadtripController { * quietly lies once you leave twenty minutes late, and the fix is arithmetic on the * schedule rather than a request. Nothing here asks the network for anything. */ -export function useMRoadtrip(planner: TripPlanner): MRoadtripController { - const { roadtripRoutes, selectedDayId, days } = planner +export function useMRoadtrip(planner: TripPlanner, forDayId?: number | null): MRoadtripController { + const { roadtripRoutes, days } = planner + // The day pager draws the stages beside the selected one too, each through its own + // instance of this hook. Left out, the day is the planner's selection. + const selectedDayId = forDayId === undefined ? planner.selectedDayId : forDayId const vehicle = useRoadtripSettings(s => s.roadtrip_vehicle, planner.tripId) const [minutes, setMinutes] = useState(localMinutes) const [offline, setOffline] = useState(isEffectivelyOffline) diff --git a/client/src/native/haptics.test.ts b/client/src/native/haptics.test.ts index 4dc860c01..c5592544d 100644 --- a/client/src/native/haptics.test.ts +++ b/client/src/native/haptics.test.ts @@ -1,16 +1,18 @@ -import { Haptics, NotificationType } from '@capacitor/haptics'; +import { Haptics, ImpactStyle, NotificationType } from '@capacitor/haptics'; import { beforeEach, describe, expect, it, vi } from 'vitest'; -import { toastHaptic } from './haptics'; +import { tickHaptic, toastHaptic } from './haptics'; import { isNativeApp } from './platform'; vi.mock('@capacitor/haptics', () => ({ - Haptics: { notification: vi.fn() }, + Haptics: { notification: vi.fn(), impact: vi.fn() }, + ImpactStyle: { Light: 'LIGHT' }, NotificationType: { Success: 'SUCCESS', Warning: 'WARNING', Error: 'ERROR' }, })); vi.mock('./platform', () => ({ isNativeApp: vi.fn() })); beforeEach(() => { vi.mocked(Haptics.notification).mockReset().mockResolvedValue(); + vi.mocked(Haptics.impact).mockReset().mockResolvedValue(); vi.mocked(isNativeApp).mockReturnValue(true); }); @@ -42,3 +44,16 @@ describe('toastHaptic', () => { vi.unstubAllGlobals(); }); }); + +describe('tickHaptic', () => { + it('gives a light detent in the app', () => { + tickHaptic(); + expect(Haptics.impact).toHaveBeenCalledWith({ style: ImpactStyle.Light }); + }); + + it('stays still in a browser', () => { + vi.mocked(isNativeApp).mockReturnValue(false); + tickHaptic(); + expect(Haptics.impact).not.toHaveBeenCalled(); + }); +}); diff --git a/client/src/native/haptics.ts b/client/src/native/haptics.ts index b88f9605e..da6cabb12 100644 --- a/client/src/native/haptics.ts +++ b/client/src/native/haptics.ts @@ -1,4 +1,4 @@ -import { Haptics, NotificationType } from '@capacitor/haptics'; +import { Haptics, ImpactStyle, NotificationType } from '@capacitor/haptics'; import { isNativeApp } from './platform'; import { reportNativeFailure } from './reportFailure'; @@ -18,3 +18,12 @@ export function toastHaptic(type: string): void { if (!feedback || !isNativeApp()) return; Haptics.notification({ type: feedback }).catch(reportNativeFailure); } + +/** + * The light detent a native pager or picker gives when it lands on a new page: + * a swiped-to day, a sheet snapping to a stop. Does nothing in a browser. + */ +export function tickHaptic(): void { + if (!isNativeApp()) return; + Haptics.impact({ style: ImpactStyle.Light }).catch(reportNativeFailure); +} diff --git a/client/tests/unit/mobile/trip/MPlanTimeline.test.tsx b/client/tests/unit/mobile/trip/MPlanTimeline.test.tsx index e49008147..e348b4996 100644 --- a/client/tests/unit/mobile/trip/MPlanTimeline.test.tsx +++ b/client/tests/unit/mobile/trip/MPlanTimeline.test.tsx @@ -700,35 +700,45 @@ describe('MPlanTimeline', () => { expect(mocks.tl.openTransitJourney).toHaveBeenCalledWith(TRANSIT_RES) }) }) - describe('day swipe (#2051)', () => { + describe('day pager (#2051)', () => { const DAYS = [ { id: 1, trip_id: 1, day_number: 1 }, DAY, { id: 3, trip_id: 1, day_number: 3 }, ] as unknown as Day[] - const panel = (container: HTMLElement) => container.firstElementChild as HTMLElement + const strip = (container: HTMLElement) => container.querySelector('[data-day-pager]') as HTMLElement + const pages = (container: HTMLElement) => Array.from(strip(container).children) as HTMLElement[] + const current = (container: HTMLElement) => strip(container).querySelector('[data-page-active]') as HTMLElement - /** A committing left swipe across the whole panel. */ - function swipe(el: HTMLElement, from = 300, to = 180) { - fireEvent.touchStart(el, { touches: [{ clientX: from, clientY: 300 }] }) - fireEvent.touchMove(el, { touches: [{ clientX: from - 20, clientY: 300 }] }) - fireEvent.touchMove(el, { touches: [{ clientX: to, clientY: 300 }] }) - fireEvent.touchEnd(el, { touches: [], changedTouches: [{ clientX: to, clientY: 300 }] }) + /** The strip comes to rest with the page of `dayId` filling it. jsdom has no + * layout, so the rects say where each page sits. */ + function land(container: HTMLElement, dayId: number) { + const s = strip(container) + s.getBoundingClientRect = () => ({ left: 0 }) as DOMRect + for (const page of pages(container)) { + page.getBoundingClientRect = () => ({ left: page.dataset.dayId === String(dayId) ? 0 : 400 }) as DOMRect + } + fireEvent(s, new Event('scrollend')) } - it('FE-MOB-PLTL-039: swiping the panel selects the next day without re-framing the map', async () => { + it('FE-MOB-PLTL-039: landing on the next page selects that day without re-framing the map', () => { const { container, planner } = renderTimeline({}, { days: DAYS, selectedDayId: 2 }) - swipe(panel(container)) + land(container, 3) // skipFit must be true: the map stays mounted under the timeline, and // re-fitting it here would move it somewhere nobody asked for. - await waitFor(() => expect(planner.handleSelectDay).toHaveBeenCalledWith(3, true)) + expect(planner.handleSelectDay).toHaveBeenCalledWith(3, true) }) - it('FE-MOB-PLTL-040: the header chip strip is excluded from the swipe zone', () => { + it('FE-MOB-PLTL-040: draws the neighbours as inert pages around the live current day', () => { const { container } = renderTimeline({}, { days: DAYS, selectedDayId: 2 }) - expect(container.querySelector('[data-hswipe-ignore]')).toBeInTheDocument() + expect(pages(container).map(p => p.dataset.dayId)).toEqual(['1', '2', '3']) + expect(current(container).dataset.dayId).toBe('2') + for (const page of pages(container).filter(p => p !== current(container))) { + expect(page).toHaveAttribute('inert') + expect(page).toHaveAttribute('aria-hidden', 'true') + } }) it('FE-MOB-PLTL-041: the live region is present and silent until a swipe lands', () => { @@ -740,42 +750,45 @@ describe('MPlanTimeline', () => { expect(live).toHaveTextContent('') }) - it('FE-MOB-PLTL-042: a committed swipe announces the day it reached', async () => { + it('FE-MOB-PLTL-042: a landed swipe announces the day it reached', async () => { const { container } = renderTimeline({}, { days: DAYS, selectedDayId: 2 }) - swipe(panel(container)) + land(container, 3) await waitFor(() => expect(container.querySelector('[role="status"]')) .toHaveTextContent('mobileTrip.dayAnnounce:3,3')) }) - it('FE-MOB-PLTL-043: edit mode keeps both the swipe and the long-press reorder', async () => { + it('FE-MOB-PLTL-043: edit mode keeps the pager, and only the current day arms the long-press reorder', () => { const { container, planner } = renderTimeline({}, { days: DAYS, selectedDayId: 2 }, { mode: 'edit' }) - swipe(panel(container)) + const armed = Array.from(container.querySelectorAll('.overflow-y-auto')).filter(c => c.hasAttribute('data-touch-drag')) + expect(armed).toHaveLength(1) + expect(armed[0]).toBe(card(current(container))) - await waitFor(() => expect(planner.handleSelectDay).toHaveBeenCalledWith(3, true)) - expect(card(container)).toHaveAttribute('data-touch-drag') + land(container, 1) + expect(planner.handleSelectDay).toHaveBeenCalledWith(1, true) }) - it('FE-MOB-PLTL-044: a plain tap on a place row still opens it', () => { - const { planner } = renderTimeline({}, { days: DAYS, selectedDayId: 2 }) + it('FE-MOB-PLTL-044: a plain tap on a place row of the current day still opens it', () => { + const { container, planner } = renderTimeline({}, { days: DAYS, selectedDayId: 2 }) - fireEvent.click(screen.getByText('Ueno Park')) + fireEvent.click(within(current(container)).getByText('Ueno Park')) expect(planner.handlePlaceClick).toHaveBeenCalledWith(102, 12) }) - it('FE-MOB-PLTL-045: nothing narrows touch-action, and the excluded strip stays tappable', () => { - const { container, shell } = renderTimeline({}, { days: DAYS, selectedDayId: 2 }) + it('FE-MOB-PLTL-045: an open leg menu holds the strip still, and nothing narrows touch-action', () => { + const { container } = renderTimeline({}, { days: DAYS, selectedDayId: 2 }, { mode: 'edit' }) + expect(strip(container)).toHaveClass('overflow-x-auto') // touch-action intersects down the tree, so a pan-y here would take the // header strip's own horizontal pan with it. - expect(panel(container).style.touchAction).toBe('') - expect(card(container).style.touchAction).toBe('') + expect(strip(container).style.touchAction).toBe('') + expect(card(current(container)).style.touchAction).toBe('') - fireEvent.click(screen.getByLabelText('day.overview')) - expect(shell.openSheet).toHaveBeenCalledWith('day', { dayId: 2 }) + fireEvent.click(within(current(container)).getByText('7 min').closest('button') as HTMLElement) + expect(strip(container)).toHaveClass('overflow-x-hidden') }) }) }) diff --git a/client/tests/unit/mobile/trip/MRoadtripTab.test.tsx b/client/tests/unit/mobile/trip/MRoadtripTab.test.tsx index e410a77bc..027b3c67e 100644 --- a/client/tests/unit/mobile/trip/MRoadtripTab.test.tsx +++ b/client/tests/unit/mobile/trip/MRoadtripTab.test.tsx @@ -19,7 +19,7 @@ import { openLeg } from '../../../helpers/legAlternatives' // reads two flags out of it, so the hook is the smaller seam. const mocks = vi.hoisted(() => ({ prefs: {} as Record, - swipe: {} as { onSelectDay: (id: number) => void; describeDay: (i: number, n: number) => string }, + pager: {} as { onSelectDay: (id: number) => void; describeDay: (i: number, n: number) => string; locked?: boolean }, })) vi.mock('../../../../src/hooks/useRoadtripSettings', () => ({ @@ -35,18 +35,14 @@ vi.mock('../../../../src/services/photoService', () => ({ onThumbReady: () => () => {}, })) -// The swipe itself is the plan tab's, tested there; this keeps the real hook and only -// records what the road trip tab hands it. -vi.mock('../../../../src/mobile/screens/trip/plan/useMPlanDaySwipe', async importOriginal => { - const actual = await importOriginal() - return { - ...actual, - useMPlanDaySwipe: (config: Parameters[0]) => { - mocks.swipe = config as unknown as typeof mocks.swipe - return actual.useMPlanDaySwipe(config) - }, - } -}) +// The paging itself is MDayPager's, tested there. This draws only the current page, so +// the stage under test is the one on screen, and records what the tab hands the pager. +vi.mock('../../../../src/mobile/components/MDayPager', () => ({ + default: (props: { selectedDayId: number | null; renderDay: (id: number | null, active: boolean) => unknown }) => { + mocks.pager = props as unknown as typeof mocks.pager + return props.renderDay(props.selectedDayId, true) + }, +})) const DAYS = [ { id: 1, trip_id: 7, day_number: 1, date: '2026-05-01', title: null }, @@ -1041,17 +1037,22 @@ describe('MRoadtripTab', () => { }) }) - describe('day swipe', () => { + describe('day pager', () => { it('FE-MOB-RTTAB-027: steps the stage without refitting the map, and announces the day it landed on', () => { const p = planner() renderTab(p) - mocks.swipe.onSelectDay(1) + mocks.pager.onSelectDay(1) // The second argument is skipFit: the map stays where it is, the stage's own // focus points frame it. expect(p.handleSelectDay).toHaveBeenCalledWith(1, true) - expect(mocks.swipe.describeDay(0, 2)).toBe('mobileTrip.dayAnnounce:1,2') + expect(mocks.pager.describeDay(0, 2)).toBe('mobileTrip.dayAnnounce:1,2') + }) + + it('FE-MOB-RTTAB-028: an open sheet holds the stages still', () => { + renderTab(planner(), buildShell({ sheet: { kind: 'rtsearch' } as never })) + expect(mocks.pager.locked).toBe(true) }) }) })