fix(mobile): give the trip map a way back to every day

The phone map filters down to one day and had no way back out. The chip
rail can only swap one day for another, the second tap on the active chip
is the day sheet, and the seed guard deliberately does not re-seed — so a
day picked on the map stayed picked until you left the trip and came back
(#2257). Desktop has had the deselect since the day header got it.

Its own round control beside the rail, map view only: the plan timeline is
single-day, so there is nothing to widen there, and the day sheet keeps the
one route into it that also exists on the map. It toggles — the first press
parks the day it came from and frames the whole trip, the second puts that
day back with its route, or falls back to the focus day if a remote delete
retired it in between. Leaving the map restores it too, since an empty
timeline would be the worse answer.
This commit is contained in:
Maurice
2026-09-06 13:05:35 +02:00
committed by Maurice
parent 8eda1475c3
commit 04b31ec2e5
25 changed files with 158 additions and 12 deletions
@@ -4,7 +4,7 @@ import { buildPlanner, buildShell } from '../../../helpers/mobileTrip'
import type { MTripShellApi, TripPlanner } from '../../../../src/mobile/screens/trip/MTripShell'
import type { Day, PackingItem, TodoItem } from '../../../../src/types'
// FE-MOB-SHELL-001 to FE-MOB-SHELL-046
// FE-MOB-SHELL-001 to FE-MOB-SHELL-051
const mocks = vi.hoisted(() => ({ planner: {} as TripPlanner }))
@@ -504,6 +504,75 @@ describe('MTripShell', () => {
expect(scrollIntoView).toHaveBeenCalledWith({ behavior: 'auto', inline: 'center', block: 'nearest' })
})
})
// #2257 — the map filters down to one day, and until now nothing took that
// filter back off: the chip rail can only swap one day for another, and the
// second tap on the active chip is the day sheet. Its own control, map only.
describe('the all-days toggle (#2257)', () => {
const allDays = () => screen.getByRole('button', { name: 'mobileTrip.allDays' })
const enterMap = () => fireEvent.click(screen.getByRole('button', { name: 'mobileTrip.mapView' }))
it('FE-MOB-SHELL-047: stays off the plan view, where nothing is filtered anyway', () => {
renderShell()
expect(screen.queryByRole('button', { name: 'mobileTrip.allDays' })).not.toBeInTheDocument()
enterMap()
expect(allDays()).toBeInTheDocument()
})
it('FE-MOB-SHELL-048: drops the day and its pin filter so the whole trip comes back', () => {
const { planner } = renderShell()
enterMap()
vi.mocked(planner.setExpandedDayIds).mockClear()
fireEvent.click(allDays())
expect(planner.handleSelectDay).toHaveBeenLastCalledWith(null, false)
expect(planner.setExpandedDayIds).toHaveBeenCalledWith(null)
// The day sheet belongs to the chip, not to this button.
expect(shellApi.sheet).toBeNull()
})
it('FE-MOB-SHELL-049: a second press goes back to the day it came from', () => {
const { planner, rerenderShell } = renderShell()
enterMap()
fireEvent.click(allDays())
// The planner is a fixture, so the commit is replayed by hand.
;(planner as { selectedDayId: number | null }).selectedDayId = null
rerenderShell()
vi.mocked(planner.setExpandedDayIds).mockClear()
vi.mocked(planner.autoShowRoute).mockClear()
fireEvent.click(allDays())
expect(planner.handleSelectDay).toHaveBeenLastCalledWith(11, false)
expect(planner.setExpandedDayIds).toHaveBeenCalledWith(new Set([11]))
expect(planner.autoShowRoute).toHaveBeenCalled()
})
it('FE-MOB-SHELL-050: leaving the map puts a day back, the timeline has no all-days state', () => {
const { planner, rerenderShell } = renderShell()
enterMap()
fireEvent.click(allDays())
;(planner as { selectedDayId: number | null }).selectedDayId = null
rerenderShell()
fireEvent.click(screen.getByRole('button', { name: 'mobileTrip.listView' }))
expect(planner.handleSelectDay).toHaveBeenLastCalledWith(11, true)
})
it('FE-MOB-SHELL-051: the active chip still opens the day sheet on the map', () => {
const { planner } = renderShell()
enterMap()
vi.mocked(planner.handleSelectDay).mockClear()
fireEvent.click(screen.getByRole('button', { name: 'Sat 2' }))
expect(shellApi.sheet).toEqual({ id: 'day', payload: { dayId: 11 } })
expect(planner.handleSelectDay).not.toHaveBeenCalled()
})
})
})
describe('buildShell fixture', () => {