From 8e38749bc3941a99e07734d99b9d4d1307f38149 Mon Sep 17 00:00:00 2001 From: Maurice Date: Thu, 19 Nov 2026 21:45:21 +0100 Subject: [PATCH] fix(transit): show every stop name and each ride's arrival in the folded-out itinerary The same gap as on the phone (#3139) in the desktop day plan's folded-out transit row and the assistant's transit card: each ride cut its stop names to one line and showed only its departure, and a walk cut its target. The names and the walk target now wrap, and each ride shows its arrival under its departure. The phone's booking sheet lets the route line under its title wrap too. --- .../Planner/transitDisplay.test.tsx | 47 +++++++++++++++++++ .../src/components/Planner/transitDisplay.tsx | 17 ++++--- .../screens/trip/sheets/MTransportSheet.tsx | 1 + 3 files changed, 58 insertions(+), 7 deletions(-) create mode 100644 client/src/components/Planner/transitDisplay.test.tsx diff --git a/client/src/components/Planner/transitDisplay.test.tsx b/client/src/components/Planner/transitDisplay.test.tsx new file mode 100644 index 000000000..0904b1ac6 --- /dev/null +++ b/client/src/components/Planner/transitDisplay.test.tsx @@ -0,0 +1,47 @@ +// FE-PLANNER-TRANSITDISPLAY-001 to FE-PLANNER-TRANSITDISPLAY-003 +import { describe, expect, it } from 'vitest'; +import { render, screen } from '../../../tests/helpers/render'; +import type { TransitLegDisplay } from './transitDisplay'; +import { TransitItineraryInline, TransitWalkDivider } from './transitDisplay'; + +const t = (key: string, params?: Record) => + params ? `${key}:${Object.values(params).join(',')}` : key; + +const ride: TransitLegDisplay = { + mode: 'RAIL', + line: 'XC', + duration: 1260, + from: { name: 'Basingstoke', time: '12:48' }, + to: { name: 'Reading', time: '13:09' }, +}; +const walk: TransitLegDisplay = { mode: 'WALK', duration: 240, to: { name: 'Reading station, Station Approach' } }; + +/** Whether a rendered element clips its text to one line. */ +function clipsToOneLine(el: HTMLElement): boolean { + return el.style.whiteSpace === 'nowrap' || el.style.textOverflow === 'ellipsis'; +} + +describe('TransitItineraryInline (#3139)', () => { + it('FE-PLANNER-TRANSITDISPLAY-001: a ride shows both stop names in full', () => { + render(); + for (const name of ['Basingstoke', 'Reading']) { + const el = screen.getByText(name); + expect(clipsToOneLine(el)).toBe(false); + expect(el.style.overflowWrap).toBe('anywhere'); + } + }); + + it('FE-PLANNER-TRANSITDISPLAY-002: a ride shows its arrival time under its departure', () => { + render(); + expect(screen.getByText('13:09')).toBeInTheDocument(); + expect(screen.getAllByText('12:48')).toHaveLength(2); + }); +}); + +describe('TransitWalkDivider (#3139)', () => { + it('FE-PLANNER-TRANSITDISPLAY-003: the walk target wraps instead of being cut off', () => { + render(); + const text = screen.getByText(/transit\.walkTo:Reading station, Station Approach/); + expect(clipsToOneLine(text)).toBe(false); + }); +}); diff --git a/client/src/components/Planner/transitDisplay.tsx b/client/src/components/Planner/transitDisplay.tsx index 7ed222002..5ab296711 100644 --- a/client/src/components/Planner/transitDisplay.tsx +++ b/client/src/components/Planner/transitDisplay.tsx @@ -41,14 +41,14 @@ export function TransitWalkDivider({ leg, t, size = 'md' }: { background: `linear-gradient(to ${dir}, var(--text-faint), transparent)`, opacity: 0.55, }) - // On phones the minutes lead so a long stop name only ever clips the name. + // On phones the minutes lead, so they stay on the first line when a long stop name wraps. const text = isMobile ? `${mins ? `${t('transit.min', { count: mins })} · ` : ''}${t('transit.walkTo', { name: leg.to?.name || '' })}` : `${t('transit.walkTo', { name: leg.to?.name || '' })}${mins ? ` · ${t('transit.min', { count: mins })}` : ''}` return (
- + {text} @@ -72,8 +72,10 @@ export function TransitItineraryInline({ legs, t }: { const mins = leg.duration ? Math.round(leg.duration / 60) : null return (
- - {leg.from?.time || ''} + {/* Departure beside the stops, arrival under it (#3139). */} + + {leg.from?.time || ''} + {leg.to?.time && {leg.to.time}}
-
- {leg.from?.name} + {/* The folded-out itinerary is where a journey is read in full: stop names wrap (#3139). */} +
+ {leg.from?.name} - {leg.to?.name} + {leg.to?.name}
{[ diff --git a/client/src/mobile/screens/trip/sheets/MTransportSheet.tsx b/client/src/mobile/screens/trip/sheets/MTransportSheet.tsx index 392dcc909..0c24d35cb 100644 --- a/client/src/mobile/screens/trip/sheets/MTransportSheet.tsx +++ b/client/src/mobile/screens/trip/sheets/MTransportSheet.tsx @@ -238,6 +238,7 @@ export default function MTransportSheet({ planner, shell }: MTripSheetsProps) { icon={} title={{res.title}} sub={subParts.length > 0 ? subParts.join(' · ') : undefined} + subWrap onClose={shell.closeSheet} closeLabel={t('common.close')} />