fix(transit): show every stop name and each ride's arrival in the journey details

The expanded transit card on the phone cut a ride's "from -> to" line to
one line, so a long first stop pushed the destination out of sight, and
it showed only the departure of each ride. The phone's booking sheet and
the desktop leg list (booking dialog, booking card, journey modal) cut
the stop names and the sheet title the same way.

The detail views now let stop names, walk targets and the booking title
wrap instead of truncating, and the expanded card shows each ride's
arrival time under its departure. The collapsed card still shortens its
headline, since expanding it shows everything.

Closes #3139
This commit is contained in:
Maurice
2026-11-19 21:21:05 +01:00
parent ac01925be7
commit 61674cf918
6 changed files with 55 additions and 12 deletions
@@ -54,6 +54,14 @@ describe('TransitLegs', () => {
expect(screen.getByText('BVG')).toBeInTheDocument();
});
it('FE-PLANNER-BKTRANSIT-009: stop names and a walk target wrap instead of being cut off (#3139)', () => {
render(<TransitLegs legs={[ride, walk]} compact />);
for (const text of ['Alexanderplatz', 'Eberswalder Str.', 'Walk to Mauerpark']) {
expect(screen.getByText(text)).not.toHaveClass('truncate');
expect(screen.getByText(text)).toHaveClass('break-words');
}
});
it('FE-PLANNER-BKTRANSIT-006: a walk reads as one and leaves out the ride facts', () => {
render(<TransitLegs legs={[walk]} compact />);
expect(screen.getByText('Walk to Mauerpark')).toBeInTheDocument();
@@ -48,9 +48,11 @@ export function TransitLegs({ legs, compact = false }: { legs: TransitLegDisplay
}}>{leg.line || leg.mode}</span>
)}
<div className={`flex min-w-0 flex-1 flex-col ${compact ? 'gap-1' : 'gap-1.5'}`}>
<div className="flex min-w-0 items-center gap-1 font-medium text-content" style={fs(compact ? 12 : 13, 'body')}>
{walk ? <span className="truncate text-content-muted">{t('transit.walkTo', { name: leg.to?.name || '' })}</span> : (
<><span className="truncate">{leg.from?.name}</span><ArrowRight size={compact ? 11 : 12} strokeWidth={2} className="flex-none text-content-faint" /><span className="truncate">{leg.to?.name}</span></>
{/* Detail views show a stop name whole: the names wrap and the
arrow moves to the next line with them when it has to (#3139). */}
<div className="flex min-w-0 flex-wrap items-center gap-1 font-medium text-content" style={fs(compact ? 12 : 13, 'body')}>
{walk ? <span className="min-w-0 break-words text-content-muted [overflow-wrap:anywhere]">{t('transit.walkTo', { name: leg.to?.name || '' })}</span> : (
<><span dir="auto" className="min-w-0 break-words [overflow-wrap:anywhere]">{leg.from?.name}</span><ArrowRight size={compact ? 11 : 12} strokeWidth={2} className="flex-none text-content-faint" /><span dir="auto" className="min-w-0 break-words [overflow-wrap:anywhere]">{leg.to?.name}</span></>
)}
</div>
<TransitMetaBadges size={compact ? 'sm' : 'md'} items={[
@@ -350,8 +350,11 @@ function TransitLegRows({ legs, t }: { legs: TransitLegDisplay[]; t: Translation
const hasSeg = i < legs.length - 1
return (
<div key={i} className="flex gap-[9px]">
<span className="w-9 flex-none pt-[9px] text-end font-geist text-[0.65625rem] font-semibold tabular-nums text-m-muted">
{isWalk ? '' : leg.from?.time?.slice(0, 5) || ''}
{/* A ride's departure stands beside its stops, its arrival at the
bottom of its row, so the open card holds the whole journey (#3139). */}
<span className="flex w-9 flex-none flex-col justify-between py-[9px] text-end font-geist text-[0.65625rem] font-semibold tabular-nums text-m-muted">
<span>{isWalk ? '' : leg.from?.time?.slice(0, 5) || ''}</span>
{!isWalk && leg.to?.time && <span className="text-m-faint">{leg.to.time.slice(0, 5)}</span>}
</span>
<div className="flex w-3 flex-none flex-col items-center">
{isWalk ? (
@@ -371,16 +374,16 @@ function TransitLegRows({ legs, t }: { legs: TransitLegDisplay[]; t: Translation
</div>
<div className="min-w-0 flex-1 py-[7px]">
{isWalk ? (
<div className="truncate font-geist text-[0.6875rem] font-semibold text-m-muted">
<div className="break-words font-geist text-[0.6875rem] font-semibold text-m-muted [overflow-wrap:anywhere]">
<Footprints size={10} strokeWidth={2.2} className="me-1 inline-block align-[-1px]" />
{[mins ? t('transit.min', { count: mins }) : '', t('transit.walkTo', { name: leg.to?.name || '' })]
.filter(Boolean).join(' · ')}
</div>
) : (
<div>
<div className="flex items-center gap-1.5">
<LineBadge leg={leg} className="flex-none" />
<span className="truncate text-[0.78125rem] font-bold">
<div className="flex items-start gap-1.5">
<LineBadge leg={leg} className="mt-px flex-none" />
<span dir="auto" className="min-w-0 break-words text-[0.78125rem] font-bold [overflow-wrap:anywhere]">
{flowText([leg.from?.name, leg.to?.name].filter((n): n is string => !!n))}
</span>
</div>
@@ -236,7 +236,7 @@ export default function MTransportSheet({ planner, shell }: MTripSheetsProps) {
<div className="flex-none px-[18px] pt-4">
<TileHeader
icon={<ResIcon size={19} strokeWidth={1.8} />}
title={<span dir="auto" className="truncate text-[1rem]">{res.title}</span>}
title={<span dir="auto" className="min-w-0 break-words text-[1rem] [overflow-wrap:anywhere]">{res.title}</span>}
sub={subParts.length > 0 ? subParts.join(' · ') : undefined}
onClose={shell.closeSheet}
closeLabel={t('common.close')}
@@ -314,9 +314,9 @@ export default function MTransportSheet({ planner, shell }: MTripSheetsProps) {
<span className="text-m-muted">{t('transit.walkTo', { name: leg.to?.name || '' })}</span>
) : (
<>
<span dir="auto" className="truncate">{leg.from?.name}</span>
<span dir="auto" className="min-w-0 break-words [overflow-wrap:anywhere]">{leg.from?.name}</span>
<ArrowRight size={10} strokeWidth={2} className="flex-none text-m-faint" />
<span dir="auto" className="truncate">{leg.to?.name}</span>
<span dir="auto" className="min-w-0 break-words [overflow-wrap:anywhere]">{leg.to?.name}</span>
</>
)}
</div>
@@ -327,6 +327,18 @@ describe('TransitRow', () => {
expect(screen.getByText('transit.min:1 · transit.walkTo:Hotel')).toBeInTheDocument()
})
it('FE-MOB-PLROW-046: the expanded legs show every stop name in full and each ride arrival time (#3139)', () => {
const { container } = render(<TransitRow {...base} open />)
const ride = screen.getByText('Shibuya Sta. → Asakusa Sta.')
expect(ride).not.toHaveClass('truncate')
expect(ride).toHaveClass('break-words')
expect(screen.getByText('transit.min:4 · transit.walkTo:Shibuya Sta.')).not.toHaveClass('truncate')
expect(screen.getByText('10:30')).toBeInTheDocument()
// the departure keeps its place beside the arrival
expect(container.textContent).toContain('10:05')
})
it('FE-MOB-PLROW-024: tapping the header toggles the row', () => {
const onToggle = vi.fn()
render(<TransitRow {...base} open={false} onToggle={onToggle} />)
@@ -144,6 +144,24 @@ describe('MTransportSheet', () => {
expect(screen.getByText('Prater')).toBeInTheDocument()
})
it('FE-MOB-TRSH-025: the title and every stop name wrap instead of being cut off (#3139)', () => {
const res = {
...FLIGHT, type: 'transit', title: 'Basingstoke station → Reading station', endpoints: [], metadata: {
transit: {
legs: [{
mode: 'RAIL', line: 'CrossCountry', duration: 1260,
from: { name: 'Basingstoke', time: '12:48' }, to: { name: 'Reading', time: '13:09' },
}],
},
},
} as unknown as Reservation
render(<MTransportSheet planner={makePlanner({ reservations: [res] })} shell={makeShell()} />)
expect(screen.getByText('Basingstoke station → Reading station')).not.toHaveClass('truncate')
expect(screen.getByText('Basingstoke')).not.toHaveClass('truncate')
expect(screen.getByText('Reading')).not.toHaveClass('truncate')
expect(screen.getByText('Reading')).toHaveClass('break-words')
})
it('FE-MOB-TRSH-010: shows the pending status and the booking code unblurred by default', () => {
render(<MTransportSheet planner={makePlanner()} shell={makeShell()} />)
expect(screen.getByText('Pending')).toBeInTheDocument()