fix(mobile): level card columns, the day framed beside the plan, the reader's place kept across a fold

From a screen by screen pass over the iPad and foldable sizes:

- Card lists (transports, bookings, tasks, polls) flow down their columns
  instead of filling rows, so the columns start level and a short card no
  longer ends above its neighbour in a ragged row. The cards' own top
  margin gives way to an even gap under each, so every column starts on
  one line.
- A booking's or transport's title may take two lines in a column of a wide
  window instead of being cut after a few words.
- The map beside the plan opened too close: the opening frame was worked
  out for the window, not the narrower map, and Leaflet rounded its zoom up
  to the next whole level, so the day ran off the top and bottom. The map
  now opens at the whole level that fits and, once it knows its own size,
  works the frame out again for it (OpeningFrameFit). On a wide window the
  touch shell frames a day clear of its floating toolbar and corner
  buttons.
- Costs and to-dos in two panes are one element tree with the stacked
  arrangement, so a rotation or a fold between them keeps what is typed or
  open in either pane, and the row at the top of the list stays at the top.
- The place sheet's category pill has room for its name on a wide window.
This commit is contained in:
Maurice
2026-11-07 18:58:33 +01:00
parent d259ecb11c
commit b644235eb6
12 changed files with 302 additions and 47 deletions
+31 -1
View File
@@ -4,6 +4,7 @@ import { render, screen } from '../../../tests/helpers/render'
import { act, fireEvent, waitFor } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import { resetAllStores } from '../../../tests/helpers/store'
import { setSizeClass } from '../../../tests/helpers/sizeClass'
import { buildPlace, buildReservation } from '../../../tests/helpers/factories'
import { AMAP_ROAD, AMAP_SATELLITE, MAP_MAX_ZOOM, OPENTOPOMAP_TILE_URL } from '../../constants/mapDefaults'
import { useAuthStore } from '../../store/authStore'
@@ -16,6 +17,8 @@ import { renderIconMarkup } from '../../utils/iconMarkup'
const mapMock = vi.hoisted(() => ({
getContainer: vi.fn(() => document.createElement('div')),
getCenter: vi.fn(() => ({ lat: 0, lng: 0 })),
// The map fills the window here, so the opening frame stands (OpeningFrameFit).
getSize: vi.fn(() => ({ x: window.innerWidth, y: window.innerHeight })),
panTo: vi.fn(),
setView: vi.fn(),
fitBounds: vi.fn(),
@@ -204,6 +207,13 @@ vi.mock('../../services/photoService', () => ({
getAllThumbs: vi.fn(() => ({})),
}))
// The app shows the touch shell at every size; a test can say it does (undefined: as in a browser).
const shell = vi.hoisted(() => ({ phone: undefined as boolean | undefined }))
vi.mock('../../mobile/useIsPhone', async (importOriginal) => {
const actual = await importOriginal<typeof import('../../mobile/useIsPhone')>()
return { ...actual, useIsPhone: () => shell.phone ?? actual.useIsPhone() }
})
vi.mock('./gcj02Crs', () => ({
crsForBasemap: (gcj02: boolean) => gcj02 ? { code: 'TREK:GCJ02' } : undefined,
}))
@@ -227,6 +237,7 @@ const ORIGINAL_WIDTH = window.innerWidth
afterEach(() => {
vi.clearAllMocks()
shell.phone = undefined
resetAllStores()
clusterMock.markers.clear()
clusterMock.asked.length = 0
@@ -1296,7 +1307,8 @@ describe('MapView selection panning (#921)', () => {
afterEach(() => {
delete projectable.project
delete projectable.unproject
delete projectable.getSize
// Back to the map that fills the window (the mock's own size).
projectable.getSize = vi.fn(() => ({ x: window.innerWidth, y: window.innerHeight }))
})
it('FE-COMP-MAPVIEW-090: pans the pin back out once the card measured taller than the allowance', () => {
@@ -1574,6 +1586,24 @@ describe('MapView bounds fitting', () => {
expect(mapMock.fitBounds.mock.calls[2][1]).toMatchObject({ paddingTopLeft: [40, 20], paddingBottomRight: [40, 20] })
})
it('FE-COMP-MAPVIEW-094: opens framed at the whole zoom level that fits, not the nearest one', () => {
// A day spread so that its exact fit lies between two levels.
const places = [buildMapPlace({ id: 1, lat: 34.9671, lng: 135.7727 }), buildMapPlace({ id: 2, lat: 35.005, lng: 135.7649 })]
render(<MapView places={places} />)
const zoom = Number(screen.getByTestId('map-container').getAttribute('data-zoom'))
expect(Number.isInteger(zoom)).toBe(true)
})
it('FE-COMP-MAPVIEW-093: on an iPad the touch shell frames a day clear of its floating toolbar and corner buttons', () => {
shell.phone = true
setSizeClass('wide')
const places = [buildMapPlace({ id: 1, lat: 35, lng: 135.7 }), buildMapPlace({ id: 2, lat: 35.04, lng: 135.78 })]
const { rerender } = render(<MapView places={places} fitKey={1} />)
rerender(<MapView places={places} fitKey={2} />)
const opts = mapMock.fitBounds.mock.calls[mapMock.fitBounds.mock.calls.length - 1]?.[1]
expect(opts).toMatchObject({ paddingTopLeft: [40, 84], paddingBottomRight: [40, 56] })
})
it('FE-COMP-MAPVIEW-079: the caller padding is read by value, so only new numbers refit the points on screen', () => {
const leg: [number, number][] = [[48.1, 2.1], [48.3, 2.4]]
const { rerender } = render(