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(ui): full-height document previews, and tooltips only on keyboard focus

Maurice350a1444576d
diff --git a/client/src/components/Budget/CostsTable.tsx b/client/src/components/Budget/CostsTable.tsx
index e12cb0d93..850b50f63 100644
--- a/client/src/components/Budget/CostsTable.tsx
+++ b/client/src/components/Budget/CostsTable.tsx
@@ -85,7 +85,7 @@ export default function CostsTable(p: CostsTableProps) {
// A new row takes the latest date of its category, so back-filling a day goes quickly.
const add = async (category: string) => {
- const dates = p.items.filter(e => catMeta(e.category).key === category && e.expense_date).map(e => e.expense_date as string).sort()
+ const dates = p.items.filter(e => catMeta(e.category).key === category && e.expense_date).map(e => e.expense_date as string).sort((a, b) => a.localeCompare(b))
const created = await p.onAdd(category, dates.length ? dates[dates.length - 1] : null)
if (created) setEditing({ id: created.id, field: 'name' })
}
diff --git a/client/src/components/Collab/CollabNotesFilePreviewPortal.tsx b/client/src/components/Collab/CollabNotesFilePreviewPortal.tsx
index 40bd3a835..49cda7ee1 100644
--- a/client/src/components/Collab/CollabNotesFilePreviewPortal.tsx
+++ b/client/src/components/Collab/CollabNotesFilePreviewPortal.tsx
@@ -92,7 +92,7 @@ export function FilePreviewPortal({ file, onClose }: FilePreviewPortalProps) {
)}
>
{(isPdf || isTxt) ? (
- <object data={authUrl ? `${authUrl}#view=FitH` : ''} type={file.mime_type} className="h-[74vh] w-full flex-1 border-0 bg-white" title={file.original_name}> {/* theme-lint-disable: a document page is white */}
+ <object data={authUrl ? `${authUrl}#view=FitH` : ''} type={file.mime_type} className="h-[74vh] w-full border-0 bg-white" title={file.original_name}> {/* theme-lint-disable: a document page is white */}
<p className="p-6 text-center text-content-muted">
<button type="button" onClick={openInNewTab} className="text-content underline" style={fs(14, 'body')}>Download</button>
</p>
diff --git a/client/src/components/Dawarich/DawarichSuggestionsPanel.test.tsx b/client/src/components/Dawarich/DawarichSuggestionsPanel.test.tsx
index cb3f29aec..81b9f0190 100644
--- a/client/src/components/Dawarich/DawarichSuggestionsPanel.test.tsx
+++ b/client/src/components/Dawarich/DawarichSuggestionsPanel.test.tsx
@@ -605,7 +605,10 @@ describe('DawarichSuggestionsPanel: the desktop tooltip', () => {
S = hookState({ suggestions: [stay({ id: 1, localDate: '2026-09-10' })] })
panel({ trips: TRIPS })
- fireEvent.focus(screen.getByRole('button', { name: 'Not a place I visited' }))
+ const action = screen.getByRole('button', { name: 'Not a place I visited' })
+ // Focus from the keyboard: the tooltip ignores focus handed back by a closing dialog.
+ vi.spyOn(action, 'matches').mockImplementation(sel => sel === ':focus-visible')
+ fireEvent.focus(action)
act(() => { vi.advanceTimersByTime(300) })
// The icon is the whole button, so without this a square is a mystery to
diff --git a/client/src/components/Files/FileManagerPdfPreviewModal.tsx b/client/src/components/Files/FileManagerPdfPreviewModal.tsx
index 4a0361e6f..713ff055b 100644
--- a/client/src/components/Files/FileManagerPdfPreviewModal.tsx
+++ b/client/src/components/Files/FileManagerPdfPreviewModal.tsx
@@ -40,7 +40,7 @@ export function PdfPreviewModal(S: FileManagerState) {
<object
data={previewFileUrl ? `${previewFileUrl}#view=FitH` : undefined}
type="application/pdf"
- className="h-[74vh] w-full flex-1 border-0"
+ className="h-[74vh] w-full border-0"
title={previewFile.original_name}
>
<p className="p-6 text-center text-content-muted">
diff --git a/client/src/components/Planner/DayDetailPanel.tsx b/client/src/components/Planner/DayDetailPanel.tsx
index 45a472a42..54e2ec408 100644
--- a/client/src/components/Planner/DayDetailPanel.tsx
+++ b/client/src/components/Planner/DayDetailPanel.tsx
@@ -17,7 +17,7 @@ import type { Day, Place, Category, Reservation, AssignmentsMap, Accommodation }
import { formatClockTime, splitReservationDateTime } from '../../utils/formatters'
import { useDayDetail, type HotelDayRange, type HotelForm, type HotelPickerMode } from './useDayDetail'
import { stayPlaces } from '../../utils/stayPlaces'
-import { DialogShell, DialogHeader, DialogTile, DialogSection, DialogFooter, DialogButton, FooterSpacer, NEUTRAL_TINT, PILL, fs } from '../shared/DialogShell'
+import { DialogShell, DialogHeader, DialogSection, DialogFooter, DialogButton, FooterSpacer, NEUTRAL_TINT, PILL, fs } from '../shared/DialogShell'
import { INPUT, PANEL, EditorField, AddRowButton, PillSelect } from '../shared/dialogParts'
import { BOX, Eyebrow, Field, RoundAction, TypeTile, toneOf, toneColor, toneTint } from './bookings/bookingParts'
import { SoftPill, TimePill, tintOf } from './planParts'
@@ -33,7 +33,7 @@ function WIcon({ main, size = 14 }: { main: string; size?: number }) {
return <Icon size={size} strokeWidth={1.8} />
}
-function cTemp(c: number | undefined, f: boolean) { return Math.round(f ? (c ?? NaN) * 9 / 5 + 32 : (c ?? NaN)) }
+function cTemp(c: number | undefined, f: boolean) { return Math.round(f ? (c ?? Number.NaN) * 9 / 5 + 32 : (c ?? Number.NaN)) }
/** What the server said when it refused a write, or the generic line. */
function apiErrorMessage(err: unknown): string | undefined {
diff --git a/client/src/components/Planner/bookings/BookingsList.tsx b/client/src/components/Planner/bookings/BookingsList.tsx
index cd588550d..0eea5c74b 100644
--- a/client/src/components/Planner/bookings/BookingsList.tsx
+++ b/client/src/components/Planner/bookings/BookingsList.tsx
@@ -37,7 +37,7 @@ export default function BookingsList(p: BookingsListProps) {
const onKeyDown = (e: KeyboardEvent<HTMLDivElement>) => {
if (e.key !== 'ArrowDown' && e.key !== 'ArrowUp') return
e.preventDefault()
- const focused = document.activeElement instanceof HTMLElement ? Number(document.activeElement.dataset.row) : NaN
+ const focused = document.activeElement instanceof HTMLElement ? Number(document.activeElement.dataset.row) : Number.NaN
const i = flat.findIndex(r => r.id === focused)
const next = flat[e.key === 'ArrowDown' ? Math.min(flat.length - 1, i + 1) : Math.max(0, i - 1)]
if (next) rootRef.current?.querySelector<HTMLElement>(`[data-row="${next.id}"]`)?.focus()
diff --git a/client/src/components/shared/Tooltip.test.tsx b/client/src/components/shared/Tooltip.test.tsx
index 3652c5356..9522bda3c 100644
--- a/client/src/components/shared/Tooltip.test.tsx
+++ b/client/src/components/shared/Tooltip.test.tsx
@@ -1,4 +1,4 @@
-// FE-W4TIP-001 to FE-W4TIP-013
+// FE-W4TIP-001 to FE-W4TIP-014
import { createRef, useRef } from 'react'
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'
import { render, screen, fireEvent, act } from '../../../tests/helpers/render'
@@ -48,9 +48,10 @@ describe('Tooltip', () => {
expect(screen.queryByRole('tooltip')).toBeNull()
})
- it('FE-W4TIP-004: focus opens and blur closes the tooltip', () => {
+ it('FE-W4TIP-004: keyboard focus opens and blur closes the tooltip', () => {
render(<Tooltip label="Delete"><button>x</button></Tooltip>)
const trigger = screen.getByRole('button')
+ vi.spyOn(trigger, 'matches').mockImplementation(sel => sel === ':focus-visible')
fireEvent.focus(trigger)
act(() => { vi.advanceTimersByTime(300) })
@@ -60,6 +61,16 @@ describe('Tooltip', () => {
expect(screen.queryByRole('tooltip')).toBeNull()
})
+ it('FE-W4TIP-014: focus handed back without the keyboard (a dialog closing) opens nothing', () => {
+ render(<Tooltip label="Export"><button>x</button></Tooltip>)
+ const trigger = screen.getByRole('button')
+ vi.spyOn(trigger, 'matches').mockReturnValue(false)
+
+ fireEvent.focus(trigger)
+ act(() => { vi.advanceTimersByTime(300) })
+ expect(screen.queryByRole('tooltip')).toBeNull()
+ })
+
it('FE-W4TIP-005: a disabled tooltip never opens', () => {
render(<Tooltip label="Delete" disabled><button>x</button></Tooltip>)
diff --git a/client/src/components/shared/Tooltip.tsx b/client/src/components/shared/Tooltip.tsx
index 04de9ac5d..83b51dfa4 100644
--- a/client/src/components/shared/Tooltip.tsx
+++ b/client/src/components/shared/Tooltip.tsx
@@ -67,7 +67,9 @@ export function Tooltip({ label, placement = 'bottom', delay = 250, disabled, ch
},
onMouseEnter: (e: React.MouseEvent) => { show(); childProps.onMouseEnter?.(e) },
onMouseLeave: (e: React.MouseEvent) => { hide(); childProps.onMouseLeave?.(e) },
- onFocus: (e: React.FocusEvent) => { show(); childProps.onFocus?.(e) },
+ // Keyboard focus only. A dialog hands focus back to the button that opened it
+ // when it closes, and a tooltip over whatever comes next is noise, not help.
+ onFocus: (e: React.FocusEvent) => { if ((e.currentTarget as HTMLElement).matches(':focus-visible')) show(); childProps.onFocus?.(e) },
onBlur: (e: React.FocusEvent) => { hide(); childProps.onBlur?.(e) },
} as TriggerProps)