fix(share): wrap a note's detail line and long words on a shared trip link (#3082)

This commit is contained in:
Maurice
2026-11-14 17:48:56 +01:00
parent f71acb08bd
commit 5be521199f
4 changed files with 73 additions and 6 deletions
+2 -2
View File
@@ -80,9 +80,9 @@ export function SharedHero({ trip, stats }: HeroProps) {
{dates}
</span>
)}
<h1 className="max-w-4xl text-balance font-bold leading-[1.1] tracking-tight" style={{ fontSize: 'calc(32px * var(--fs-scale-title, 1))' }}>{trip.title}</h1>
<h1 className="max-w-4xl text-balance font-bold leading-[1.1] tracking-tight [overflow-wrap:anywhere]" style={{ fontSize: 'calc(32px * var(--fs-scale-title, 1))' }}>{trip.title}</h1>
{trip.description && (
<p className="max-w-2xl whitespace-pre-line text-white/80" style={fs(14.5, 'body')}>{trip.description}</p> // theme-lint-disable: white type over a photo
<p className="max-w-2xl whitespace-pre-line text-white/80 [overflow-wrap:anywhere]" style={fs(14.5, 'body')}>{trip.description}</p> // theme-lint-disable: white type over a photo
)}
{stats.length > 0 && (
<div className="mt-1 flex flex-wrap gap-2">
@@ -0,0 +1,49 @@
import { describe, expect, it, vi } from 'vitest';
import { render, screen } from '../../../tests/helpers/render';
import { SharedDayCard, type SharedDayCardProps } from './SharedDayCard';
/** FE-PAGE-SHARED-DAY-001: a day note's detail line on a shared trip wraps inside its card (#3082). */
const LONG_DETAIL =
'Lorem Ipsum is simply dummy text of the printing and typesetting industry, https://example.com/a/very/long/unbroken/path/that/never/stops';
function renderDay(note: { id: number; text: string; time: string | null }) {
const props: SharedDayCardProps = {
day: { id: 9, title: 'Day One', date: '2026-07-02', day_number: 1 },
index: 0,
selected: false,
collapsed: false,
onSelect: vi.fn(),
onToggleCollapse: vi.fn(),
items: [{ type: 'note', sortKey: 0, data: note }],
stays: [],
placeCount: 0,
stopNumber: {},
categories: [],
};
return render(<SharedDayCard {...props} />);
}
describe('SharedDayCard', () => {
it('FE-PAGE-SHARED-DAY-001: a long note detail wraps in its row instead of running out of a nowrap pill', () => {
renderDay({ id: 1, text: 'Test', time: LONG_DETAIL });
const detail = screen.getByTestId('shared-note-detail');
expect(detail).toHaveTextContent(LONG_DETAIL);
expect(detail.className).toContain('[overflow-wrap:anywhere]');
expect(detail.className).toContain('min-w-0');
// Nothing between the text and the row may forbid wrapping.
let el: HTMLElement | null = screen.getByText(/Lorem Ipsum/);
for (; el && el !== document.body; el = el.parentElement) {
expect(el.className).not.toMatch(/whitespace-nowrap/);
}
});
it('FE-PAGE-SHARED-DAY-001: a leading HH:MM stays a time pill and the rest becomes the wrapping detail', () => {
renderDay({ id: 2, text: 'Museum', time: '08:30 meet at the north entrance' });
expect(screen.getByText('08:30')).toBeInTheDocument();
expect(screen.getByTestId('shared-note-detail')).toHaveTextContent('meet at the north entrance');
});
});
+20 -2
View File
@@ -7,6 +7,8 @@ import { TypeTile } from '../../components/Planner/bookings/bookingParts'
import { typeInfo } from '../../components/Planner/bookings/bookingsModel'
import { getNoteIcon } from '../../components/Planner/DayPlanSidebar.constants'
import { noteSurface } from '../../components/Planner/noteSurface'
import { SafeMarkdown } from '../../components/shared/SafeMarkdown'
import { splitNoteTime } from '../../mobile/screens/trip/lib/dayNotes'
import { useTranslation } from '../../i18n'
import { useSettingsStore } from '../../store/settingsStore'
import { getDisplayTimeForDay, getSpanPhase, type MergedItem } from '../../utils/dayMerge'
@@ -160,7 +162,7 @@ export function PlaceRow({ place, notes, number, category }: PlaceRowProps) {
</span>
<div className="min-w-0 flex-1 pt-0.5">
<div className="flex min-w-0 items-start gap-2">
<span className="min-w-0 flex-1 font-semibold text-content" style={{ ...fs(13.5, 'body'), lineHeight: 1.3 }}>{place.name}</span>
<span className="min-w-0 flex-1 font-semibold text-content [overflow-wrap:anywhere]" style={{ ...fs(13.5, 'body'), lineHeight: 1.3 }}>{place.name}</span>
{time && <TimePill className="mt-px">{time}</TimePill>}
</div>
<SharedPlaceDetails place={place} assignmentNotes={notes} />
@@ -197,9 +199,16 @@ function TransportRow({ r, dayId }: { r: SharedTransport; dayId: number }) {
)
}
/**
* A day note. Its `time` column is not a time but the note's free detail line
* (#3082): only a leading HH:MM is a real time and gets the pill, the rest is
* the owner's text and wraps under the title, rendered as the planner renders it.
* In a pill, which never wraps, a sentence ran off the edge of the card.
*/
function NoteRow({ note }: { note: { id: number; text: string; time?: string | null; icon?: string | null; color?: string | null } }) {
const skin = noteSurface(note.color)
const Icon = getNoteIcon(note.icon)
const { time, detail } = splitNoteTime(note.time)
return (
<div className="flex items-start gap-2.5 rounded-xl px-2 py-2" style={{ background: skin.background, border: `1px solid ${skin.border}` }}>
<span className="grid h-8 w-8 flex-none place-items-center rounded-[10px]" style={{ background: skin.iconBackground, color: skin.iconColor }}>
@@ -207,7 +216,16 @@ function NoteRow({ note }: { note: { id: number; text: string; time?: string | n
</span>
<div className="min-w-0 flex-1 pt-1">
<div className="whitespace-pre-wrap text-content-secondary [overflow-wrap:anywhere]" style={fs(12.5, 'body')}>{note.text}</div>
{note.time && <div className="mt-1"><TimePill>{note.time}</TimePill></div>}
{(time || detail) && (
<div className="mt-1 flex min-w-0 flex-wrap items-start gap-1.5">
{time && <TimePill>{time}</TimePill>}
{detail && (
<div data-testid="shared-note-detail" className="collab-note-md min-w-0 flex-1 basis-40 text-content-muted [overflow-wrap:anywhere]" style={{ ...fs(11.5, 'body'), lineHeight: 1.4 }}>
<SafeMarkdown>{detail}</SafeMarkdown>
</div>
)}
</div>
)}
</div>
</div>
)
@@ -56,7 +56,7 @@ export function SharedPackingView({ items }: { items: PackingItem[] }) {
{item.checked
? <CheckCircle2 size={17} strokeWidth={2} className="flex-none text-success" aria-hidden />
: <Circle size={17} strokeWidth={2} className="flex-none text-content-faint" aria-hidden />}
<span className={`min-w-0 flex-1 ${item.checked ? 'text-content-faint line-through' : 'text-content'}`} style={fs(13, 'body')}>{item.name}</span>
<span className={`min-w-0 flex-1 [overflow-wrap:anywhere] ${item.checked ? 'text-content-faint line-through' : 'text-content'}`} style={fs(13, 'body')}>{item.name}</span>
{(item.quantity ?? 1) > 1 && <span className="font-geist font-semibold tabular-nums text-content-faint" style={fs(11)}>×{item.quantity}</span>}
</li>
))}
@@ -149,7 +149,7 @@ export function SharedCostsView({ items, base, tripCurrency, convert }: CostsPro
return (
<li key={item.id} className="flex items-center gap-3 px-4 py-2.5">
<div className="min-w-0 flex-1">
<div className="text-content" style={fs(13, 'body')}>{item.name}</div>
<div className="text-content [overflow-wrap:anywhere]" style={fs(13, 'body')}>{item.name}</div>
{entered && <div className="font-geist tabular-nums text-content-faint" style={fs(11)}>{entered}</div>}
</div>
{!!item.total_price && <span className="font-geist font-semibold tabular-nums text-content" style={fs(13, 'body')}>{money(valueOf(item))}</span>}