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(mobile): show stay names whole in the day card's chip strip

Mauricefe90502955f6
diff --git a/client/src/mobile/screens/trip/plan/MPlanTimeline.tsx b/client/src/mobile/screens/trip/plan/MPlanTimeline.tsx
index 95d4b6ce7..33a7a2bf2 100644
--- a/client/src/mobile/screens/trip/plan/MPlanTimeline.tsx
+++ b/client/src/mobile/screens/trip/plan/MPlanTimeline.tsx
@@ -508,12 +508,15 @@ function TimelineHeader({ tl, dayLabel, openLabel, weatherLabel, onOpenDay, onOp
stayLabel: (chip: HotelChip) => string
}) {
const WeatherIcon = weatherIconFor(tl.weather?.main)
+ const [strip, setStrip] = useState<HTMLSpanElement | null>(null)
+ const stripFade = useEdgeFade(strip)
return (
<div className="flex items-center gap-1.5 border-b border-[color:var(--m-rowbr)] px-0.5 py-[9px]">
{/* The one horizontal scroller inside the day pager. Nested scrolling is
the browser's: while the chips overflow they pan first, and the pager
- takes over at their end or when they fit. */}
- <span className="flex min-w-0 items-center gap-1.5 overflow-x-auto">
+ takes over at their end or when they fit. The ends fade while more
+ waits behind them. */}
+ <span ref={setStrip} className={`flex min-w-0 items-center gap-1.5 overflow-x-auto ${edgeFadeClass(stripFade)}`}>
{/* The same glass controls as the edit header's: a round one when the day
is already named above it, a pill with the day's name otherwise. */}
<button
@@ -532,20 +535,20 @@ function TimelineHeader({ tl, dayLabel, openLabel, weatherLabel, onOpenDay, onOp
</>
)}
</button>
- {/* A stay gives way before anything else in the header does: its name ends
- in an ellipsis rather than under the edge or the weather (the chip's
- label says it whole), and the time after it stays. */}
+ {/* A stay's name stands whole: two stays and the weather rarely fit a
+ phone, and a name cut to a letter or two said nothing, so the strip
+ scrolls instead of squeezing the chips. */}
{tl.hotelChips.map(chip => (
<button
key={chip.key}
type="button"
onClick={() => onOpenStay(chip)}
aria-label={stayLabel(chip)}
- className={`${GLASS_CHIP} min-w-[4.5rem] shrink gap-[5px] px-2.5`}
+ className={`${GLASS_CHIP} gap-[5px] px-2.5`}
>
<HotelChipIcon variant={chip.variant} />
- {/* Its own direction, so a Latin name in an Arabic header is cut at its end, not its start. */}
- <span dir="auto" className="min-w-0 truncate">{chip.name}</span>
+ {/* Its own direction, so a Latin name reads the right way in an Arabic header. */}
+ <span dir="auto">{chip.name}</span>
{chip.time && <span className="flex-none tabular-nums text-m-muted">{chip.time.slice(0, 5)}</span>}
</button>
))}
diff --git a/client/tests/unit/mobile/trip/MPlanTimeline.test.tsx b/client/tests/unit/mobile/trip/MPlanTimeline.test.tsx
index d6178df82..5933e3102 100644
--- a/client/tests/unit/mobile/trip/MPlanTimeline.test.tsx
+++ b/client/tests/unit/mobile/trip/MPlanTimeline.test.tsx
@@ -218,13 +218,16 @@ describe('MPlanTimeline', () => {
weatherTemp: 17,
})
- // The name gives way with an ellipsis; the time after it stays, with no dot between.
+ // The name stands whole, never cut to a few letters: the chip keeps its
+ // size and the strip scrolls instead. The time follows with no dot between.
const sacher = screen.getByText('Hotel Sacher')
- expect(sacher).toHaveClass('truncate', 'min-w-0')
- // In an Arabic header a Latin name keeps its own direction, so the ellipsis lands at its end.
+ expect(sacher).not.toHaveClass('truncate')
+ // In an Arabic header a Latin name keeps its own direction.
expect(sacher).toHaveAttribute('dir', 'auto')
expect(sacher.closest('button')).toHaveTextContent('Hotel Sacher11:00')
- expect(sacher.closest('button')).toHaveClass('shrink')
+ expect(sacher.closest('button')).toHaveClass('flex-none')
+ expect(sacher.closest('button')).not.toHaveClass('shrink')
+ expect(sacher.closest('button')?.parentElement).toHaveClass('overflow-x-auto')
expect(screen.getByText('Ryokan Kyoto').closest('button')).toHaveTextContent('Ryokan Kyoto15:00')
expect(screen.getByText('Capsule Tokyo')).toBeInTheDocument()
expect(screen.getByText('17°')).toBeInTheDocument()