Skip to content

armgit / TREK

Public Imported from GitHub
0

The most complete open-source travel planner: real-time collaboration, bookings, budgets, packing lists, journals, offline PWA, SSO and an AI-ready MCP server, with planet-wide place search and routing built in.

fix(transit): show every stop name and each ride's arrival in the folded-out itinerary

Maurice8e38749bc394
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<string, string | number>) =>
+ 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(<TransitItineraryInline legs={[ride]} t={t} />);
+ 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(<TransitItineraryInline legs={[ride, { ...ride, to: { name: 'Oxford' } }]} t={t} />);
+ 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(<TransitWalkDivider leg={walk} t={t} size="sm" />);
+ 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 (
<div style={{ display: 'flex', alignItems: 'center', gap: 10, padding: size === 'sm' ? '1px 0' : '2px 0' }}>
<span style={rule('left')} />
- <span className="text-content-faint" style={{ display: 'inline-flex', alignItems: 'center', gap: 5, fontSize: size === 'sm' ? 'calc(10px * var(--fs-scale-caption, 1))' : 'calc(11.5px * var(--fs-scale-caption, 1))', fontWeight: 500, whiteSpace: 'nowrap', overflow: 'hidden', textOverflow: 'ellipsis', maxWidth: isMobile ? '85%' : '75%' }}>
+ <span className="text-content-faint" style={{ display: 'inline-flex', alignItems: 'center', gap: 5, fontSize: size === 'sm' ? 'calc(10px * var(--fs-scale-caption, 1))' : 'calc(11.5px * var(--fs-scale-caption, 1))', fontWeight: 500, textAlign: 'center', overflowWrap: 'anywhere', maxWidth: isMobile ? '85%' : '75%' }}>
<Footprints size={size === 'sm' ? 11 : 12} style={{ flexShrink: 0 }} />
{text}
</span>
@@ -72,8 +72,10 @@ export function TransitItineraryInline({ legs, t }: {
const mins = leg.duration ? Math.round(leg.duration / 60) : null
return (
<div key={i} style={{ display: 'flex', alignItems: 'flex-start', gap: 7 }}>
- <span className="text-content-muted" style={{ width: 34, flexShrink: 0, textAlign: 'end', fontSize: 'calc(10px * var(--fs-scale-caption, 1))', fontWeight: 600, paddingTop: 1 }}>
- {leg.from?.time || ''}
+ {/* Departure beside the stops, arrival under it (#3139). */}
+ <span className="text-content-muted" style={{ width: 34, flexShrink: 0, alignSelf: 'stretch', display: 'flex', flexDirection: 'column', justifyContent: 'space-between', textAlign: 'end', fontSize: 'calc(10px * var(--fs-scale-caption, 1))', fontWeight: 600, paddingTop: 1 }}>
+ <span>{leg.from?.time || ''}</span>
+ {leg.to?.time && <span className="text-content-faint">{leg.to.time}</span>}
</span>
<span style={{
display: 'inline-flex', alignItems: 'center', borderRadius: 4, padding: '0 5px',
@@ -84,10 +86,11 @@ export function TransitItineraryInline({ legs, t }: {
{leg.line || leg.mode}
</span>
<div style={{ flex: 1, minWidth: 0 }}>
- <div className="text-content" style={{ fontSize: 'calc(11px * var(--fs-scale-caption, 1))', fontWeight: 500, display: 'flex', alignItems: 'center', gap: 4, minWidth: 0 }}>
- <span style={{ overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>{leg.from?.name}</span>
+ {/* The folded-out itinerary is where a journey is read in full: stop names wrap (#3139). */}
+ <div className="text-content" style={{ fontSize: 'calc(11px * var(--fs-scale-caption, 1))', fontWeight: 500, display: 'flex', flexWrap: 'wrap', alignItems: 'center', columnGap: 4, minWidth: 0 }}>
+ <span dir="auto" style={{ minWidth: 0, overflowWrap: 'anywhere' }}>{leg.from?.name}</span>
<MoveRight size={10} className="text-content-faint" style={{ flexShrink: 0 }} />
- <span style={{ overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>{leg.to?.name}</span>
+ <span dir="auto" style={{ minWidth: 0, overflowWrap: 'anywhere' }}>{leg.to?.name}</span>
</div>
<div className="text-content-faint" style={{ fontSize: 'calc(9.5px * var(--fs-scale-caption, 1))', marginTop: 1 }}>
{[
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={<ResIcon size={19} strokeWidth={1.8} />}
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}
+ subWrap
onClose={shell.closeSheet}
closeLabel={t('common.close')}
/>