diff --git a/client/src/mobile/screens/atlas/MAtlasSearch.tsx b/client/src/mobile/screens/atlas/MAtlasSearch.tsx index 5518f62fa..24e3e5c82 100644 --- a/client/src/mobile/screens/atlas/MAtlasSearch.tsx +++ b/client/src/mobile/screens/atlas/MAtlasSearch.tsx @@ -50,7 +50,7 @@ export default function MAtlasSearch({ const q = query.trim().toLowerCase() const rows = q ? options.filter((o) => o.label.toLowerCase().includes(q)).slice(0, 6) : suggestions - const scrimCls = 'm-fade-in fixed inset-0 z-[70] flex flex-col bg-[rgba(16,16,19,.28)] px-[18px] pt-[calc(var(--m-safe-top,12px)+12px)] backdrop-blur-[22px] backdrop-saturate-[1.6]' // theme-lint-disable — fixed scrim value from the design + const scrimCls = 'm-fade-in fixed inset-0 z-[70] flex flex-col bg-[rgba(16,16,19,.28)] px-[18px] pt-[calc(var(--m-safe-top,12px)+12px)] backdrop-blur-[22px] backdrop-saturate-[1.6] wide:pt-[calc(var(--m-safe-top,12px)+72px)] wide:[&>*]:mx-auto wide:[&>*]:w-full wide:[&>*]:max-w-[640px]' // theme-lint-disable — fixed scrim value from the design return (
{ + selectDayRef.current = planner.handleSelectDay + }) useEffect(() => { if (followDayId == null) return autoShowRoute() setExpandedDayIds(new Set([followDayId])) + // Framed as the map toggle frames it, without touching the plan's scroll. + selectDayRef.current(followDayId, false) }, [followDayId, autoShowRoute, setExpandedDayIds]) + // The map's box changes with the pane (opening, hiding, a rotation or a fold + // crossing the split size), and a frame fitted to the old box leaves the day + // half outside the new one. Once the box has settled, frame the day again. + const frameDayId = MAP_TABS.has(trTab) ? planner.selectedDayId : null + const boxKey = `${split}:${paneOpen}` + const lastBoxRef = useRef(boxKey) + useEffect(() => { + if (lastBoxRef.current === boxKey) return + lastBoxRef.current = boxKey + if (frameDayId == null) return + const timer = setTimeout(() => selectDayRef.current(frameDayId, false), 340) + return () => clearTimeout(timer) + }, [boxKey, frameDayId]) + const openSheet = (id: string, payload?: unknown) => setSheet({ id, payload }) const closeSheet = () => setSheet(null) diff --git a/client/tests/unit/mobile/trip/MTripShell.wide.test.tsx b/client/tests/unit/mobile/trip/MTripShell.wide.test.tsx index 0d27e48a8..0af092d9f 100644 --- a/client/tests/unit/mobile/trip/MTripShell.wide.test.tsx +++ b/client/tests/unit/mobile/trip/MTripShell.wide.test.tsx @@ -9,7 +9,7 @@ import { useDocSyncOfferStore } from '../../../../src/store/docSyncOfferStore'; import type { Day } from '../../../../src/types'; import { buildPlanner } from '../../../helpers/mobileTrip'; import { server } from '../../../helpers/msw/server'; -import { fireEvent, render, screen, within } from '../../../helpers/render'; +import { fireEvent, render, screen, waitFor, within } from '../../../helpers/render'; import { setSizeClass } from '../../../helpers/sizeClass'; import { seedStore } from '../../../helpers/store'; @@ -142,6 +142,18 @@ describe('MTripShell on a wide window', () => { expect(screen.getByTestId('plan-timeline')).toBeInTheDocument(); }); + it('FE-MOB-SHELLW-007: the map frames the day beside the pane, and again once its box has changed', async () => { + setSizeClass('split'); + renderShell(); + // On arrival, as the map toggle frames it: the day, without the list flag. + expect(mocks.planner.handleSelectDay).toHaveBeenCalledWith(12, false); + vi.mocked(mocks.planner.handleSelectDay).mockClear(); + + fireEvent.click(screen.getByRole('button', { name: 'mobileTrip.hidePane' })); + vi.mocked(mocks.planner.handleSelectDay).mockClear(); + await waitFor(() => expect(mocks.planner.handleSelectDay).toHaveBeenCalledWith(12, false), { timeout: 1500 }); + }); + it('FE-MOB-SHELLW-004: folding to compact mid-plan keeps the map and the day, and brings the dock back', () => { setSizeClass('split'); renderShell();