From 3cd22b91ff7b5819ffb8b1f6e2ed9aa71928c62b Mon Sep 17 00:00:00 2001 From: Maurice Date: Sat, 5 Dec 2026 01:41:10 +0100 Subject: [PATCH] fix(ci): repair trip tag checks and shared booking build Restore the category label used by shared bookings, keep measured tag-menu positioning, and fix form queries and schema formatting. Collapse the Route label within narrow toolbars. --- .../src/components/Planner/DayPlanSidebar.tsx | 25 +++---------------- .../Planner/bookings/bookingParts.tsx | 12 +++++++++ .../components/Trips/TripFormModal.test.tsx | 18 ++++++------- client/src/components/Trips/TripTagField.tsx | 4 ++- shared/src/trip/trip.schema.ts | 3 ++- 5 files changed, 30 insertions(+), 32 deletions(-) diff --git a/client/src/components/Planner/DayPlanSidebar.tsx b/client/src/components/Planner/DayPlanSidebar.tsx index b9008f3a6..e54fa6d64 100644 --- a/client/src/components/Planner/DayPlanSidebar.tsx +++ b/client/src/components/Planner/DayPlanSidebar.tsx @@ -1175,7 +1175,6 @@ function useDayPlanSidebar(props: DayPlanSidebarProps) { * worse than the icon that means the same thing. The icon keeps the accessible * name, so nothing is lost but the letters. */ -const NARROW_PLAN_PX = 320 const DAY_DATE_BADGE = 'inline-flex items-center rounded-full bg-surface-card px-2 py-0.5 font-medium text-content-muted' const DayPlanSidebar = React.memo(function DayPlanSidebar(props: DayPlanSidebarProps) { @@ -1251,22 +1250,6 @@ const DayPlanSidebar = React.memo(function DayPlanSidebar(props: DayPlanSidebarP // Deleting a note asks for confirmation first — the edit/delete icons sit close together and are // easy to mis-tap on touch devices, where an accidental delete was previously unrecoverable. const [pendingDeleteNote, setPendingDeleteNote] = useState<{ dayId: number; noteId: number } | null>(null) - // The plan sidebar is resizable. Below this the route button's own word is the - // first thing that stops fitting beside the two export buttons — the icon says - // the same thing, and the accessible name still spells it out. - // - // A callback ref rather than `useRef`, so the measurement happens when the - // element exists rather than on a mount that may render nothing yet. - const [panel, setPanel] = useState(null) - const [narrowPanel, setNarrowPanel] = useState(false) - useEffect(() => { - if (!panel || typeof ResizeObserver === 'undefined') return - const measure = (): void => setNarrowPanel(panel.clientWidth < NARROW_PLAN_PX) - measure() - const ro = new ResizeObserver(measure) - ro.observe(panel) - return () => ro.disconnect() - }, [panel]) // A stable key for the current selection. A multi-day place renders one row per // day (same place_id, different assignment ids); selecting it by place_id alone // (e.g. clicking an accommodation) marks every one of those rows selected, so a @@ -1441,7 +1424,7 @@ const DayPlanSidebar = React.memo(function DayPlanSidebar(props: DayPlanSidebarP // trip switch above this, and at height 100% alone the list ran the switch's height // past the panel's clipped edge, so the last day could never be scrolled into view. // Where nothing sits above it (the mobile shell), the height still fills the panel. -
+
{/* Toolbar */} {toursEnabled && selectedDayId != null && projectDayItinerary(assignments[String(selectedDayId)] || [], true, places).some(item => item.kind === 'tour' && !item.valid) && (
@@ -2520,7 +2503,7 @@ const DayPlanSidebar = React.memo(function DayPlanSidebar(props: DayPlanSidebarP {/* Routen-Werkzeuge (ausgewählter Tag, 2+ Orte — oder 1 Ort mit Hotel-Bookend #1330 — oder Hotel-zu-Hotel-Transfertag ohne Orte #1297) */} {showRouteTools && ( -
+
{/* The day's travel mode as one segmented control. */}
+ + {t(info.chipKey)} + + ) +} + export function BookingTypeMarker({ booking, inHeader = false }: { booking: Reservation; inHeader?: boolean }) { const { t } = useTranslation() const info = typeInfo(booking.type) diff --git a/client/src/components/Trips/TripFormModal.test.tsx b/client/src/components/Trips/TripFormModal.test.tsx index 7341fa1b7..63ff66283 100644 --- a/client/src/components/Trips/TripFormModal.test.tsx +++ b/client/src/components/Trips/TripFormModal.test.tsx @@ -200,8 +200,8 @@ describe('TripFormModal', () => { const user = userEvent.setup(); seedStore(useAuthStore, { tripRemindersEnabled: true }); render(); - await user.click(screen.getByRole('button', { name: 'Reminder', exact: true })); - const reminder = within(await screen.findByRole('group', { name: 'Reminder', exact: true })); + await user.click(screen.getByRole('button', { name: /^Reminder$/ })); + const reminder = within(await screen.findByRole('group', { name: /^Reminder$/ })); expect(reminder.getByRole('button', { name: 'None' })).toBeInTheDocument(); expect(reminder.getByRole('button', { name: '1 day' })).toBeInTheDocument(); expect(reminder.getByRole('button', { name: '3 days' })).toBeInTheDocument(); @@ -213,15 +213,15 @@ describe('TripFormModal', () => { seedStore(useAuthStore, { tripRemindersEnabled: false }); render(); expect(screen.getByText(/Trip reminders are disabled/i)).toBeInTheDocument(); - expect(screen.queryByRole('button', { name: 'Reminder', exact: true })).not.toBeInTheDocument(); + expect(screen.queryByRole('button', { name: /^Reminder$/ })).not.toBeInTheDocument(); }); it('FE-COMP-TRIPFORM-021: custom reminder input appears and accepts value', async () => { const user = userEvent.setup(); seedStore(useAuthStore, { tripRemindersEnabled: true }); render(); - await user.click(screen.getByRole('button', { name: 'Reminder', exact: true })); - await user.click(await screen.findByRole('button', { name: 'Custom', exact: true })); + await user.click(screen.getByRole('button', { name: /^Reminder$/ })); + await user.click(await screen.findByRole('button', { name: /^Custom$/ })); // custom reminder input has max=30 const customInput = document.querySelector('input[max="30"]') as HTMLInputElement; expect(customInput).toBeInTheDocument(); @@ -1007,8 +1007,8 @@ describe('TripFormModal', () => { render(); await user.type(screen.getByPlaceholderText(/Summer in Japan/i), 'Reminder Trip'); - await user.click(screen.getByRole('button', { name: 'Reminder', exact: true })); - await user.click(await screen.findByRole('button', { name: '9 days', exact: true })); + await user.click(screen.getByRole('button', { name: /^Reminder$/ })); + await user.click(await screen.findByRole('button', { name: /^9 days$/ })); await submitNewTrip(user); await waitFor(() => expect(onSave).toHaveBeenCalledWith(expect.objectContaining({ reminder_days: 9 }))); @@ -1020,8 +1020,8 @@ describe('TripFormModal', () => { const onSave = vi.fn().mockResolvedValue({}); render(); - await user.click(screen.getByRole('button', { name: 'Reminder', exact: true })); - await user.click(await screen.findByRole('button', { name: 'Custom', exact: true })); + await user.click(screen.getByRole('button', { name: /^Reminder$/ })); + await user.click(await screen.findByRole('button', { name: /^Custom$/ })); const custom = document.querySelector('input[max="30"]') as HTMLInputElement; expect(custom.value).toBe('7'); diff --git a/client/src/components/Trips/TripTagField.tsx b/client/src/components/Trips/TripTagField.tsx index a2f250b6c..ae3fc085d 100644 --- a/client/src/components/Trips/TripTagField.tsx +++ b/client/src/components/Trips/TripTagField.tsx @@ -71,6 +71,7 @@ export function TripTagField({ tags, draft, onChange, onDraftChange, readOnly, i }) const menuOpen = active && suggestions.length > 0 && !!position const activeTag = menuOpen ? suggestions[highlighted] : undefined + const { flipped, ...menuStyle } = position ?? { flipped: false } useOverlay(menuOpen, closeMenu, true) const add = (name: string) => { @@ -182,7 +183,8 @@ export function TripTagField({ tags, draft, onChange, onDraftChange, readOnly, i ref={menuRef} id={menuId} className="trek-select-menu fixed z-[99999] flex flex-wrap content-start gap-1.5 overflow-y-auto overscroll-contain rounded-xl border border-edge bg-surface-card p-2 shadow-lg" - style={{ top: position.top, bottom: position.bottom, left: position.left, width: position.width, maxHeight: position.maxHeight }} + data-side={flipped ? 'top' : 'bottom'} + style={menuStyle} role="listbox" aria-label={t('dashboard.tags.existing')} > diff --git a/shared/src/trip/trip.schema.ts b/shared/src/trip/trip.schema.ts index fcf10fc9e..d98cdd36f 100644 --- a/shared/src/trip/trip.schema.ts +++ b/shared/src/trip/trip.schema.ts @@ -1,6 +1,7 @@ -import { z } from 'zod'; import { tripTagNameSchema } from '../tag/trip-tag.schema'; +import { z } from 'zod'; + /** * Trip API contract — single source of truth for the /api/trips aggregate-root * endpoints (list/create/get/update/delete a trip, cover upload, copy, members,