mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-21 11:36:05 +00:00
fix(mobile): the map frames the day beside the pane, atlas search as a centred panel
With the plan beside the map, the map frames the day once the splash has gone, and again once its box has settled after the pane opens or hides, a rotation or a fold: a frame fitted to the old box left the day half outside the new one. On a wide window the atlas country search stands as a centred panel instead of a band across the screen.
This commit is contained in:
@@ -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 (
|
||||
<div
|
||||
|
||||
@@ -433,14 +433,36 @@ export default function MTripShell({
|
||||
// With the plan beside the map, the map shows the day the plan shows: its
|
||||
// places framed, its route drawn, the other days' pins put away, exactly as
|
||||
// a phone does when it switches over to the map.
|
||||
const followDayId = split && trTab === 'plan' && view === 'plan' && mode !== 'browse' ? planner.selectedDayId : null
|
||||
// Not before the splash has gone: the map is not there to frame until then.
|
||||
const mapReady = !planner.isLoading && planner.splashDone
|
||||
const followDayId = mapReady && split && trTab === 'plan' && view === 'plan' && mode !== 'browse' ? planner.selectedDayId : null
|
||||
const { autoShowRoute, setExpandedDayIds } = planner
|
||||
const selectDayRef = useRef(planner.handleSelectDay)
|
||||
useEffect(() => {
|
||||
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)
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user