diff --git a/client/src/components/Admin/PackingTemplateManager.tsx b/client/src/components/Admin/PackingTemplateManager.tsx index be06e6e98..da62d7487 100644 --- a/client/src/components/Admin/PackingTemplateManager.tsx +++ b/client/src/components/Admin/PackingTemplateManager.tsx @@ -1,3 +1,4 @@ +import { focusRevealedEditor } from '../shared/dialogFocus' import { useTranslation } from '../../i18n' import { Plus, Trash2, Pencil, Package, X, Check, ChevronRight, FolderPlus, Loader2 } from 'lucide-react' import { fs } from '../shared/DialogShell' @@ -57,7 +58,7 @@ export default function PackingTemplateManager() { {showCreate && (
- setCreateName(e.target.value)} + setCreateName(e.target.value)} onKeyDown={e => { if (e.key === 'Enter') void handleCreateTemplate(); if (e.key === 'Escape') setShowCreate(false) }} placeholder={t('admin.packingTemplates.namePlaceholder')} className={COMPOSER_INPUT} style={fs(13, 'body')} /> @@ -101,7 +102,7 @@ export default function PackingTemplateManager() { {editingTemplate === tmpl.id ? ( - setEditTemplateName(e.target.value)} + setEditTemplateName(e.target.value)} onBlur={() => handleRenameTemplate(tmpl.id)} onKeyDown={e => { if (e.key === 'Enter') void handleRenameTemplate(tmpl.id); if (e.key === 'Escape') setEditingTemplate(null) }} aria-label={t('common.rename')} @@ -132,7 +133,7 @@ export default function PackingTemplateManager() { {/* Category header */}
{editingCatId === cat.id ? ( - setEditCatName(e.target.value)} + setEditCatName(e.target.value)} onBlur={() => handleRenameCategory(cat.id)} onKeyDown={e => { if (e.key === 'Enter') void handleRenameCategory(cat.id); if (e.key === 'Escape') setEditingCatId(null) }} aria-label={t('common.rename')} @@ -162,7 +163,7 @@ export default function PackingTemplateManager() {
{editingItemId === item.id ? ( <> - setEditItemName(e.target.value)} + setEditItemName(e.target.value)} onKeyDown={e => { if (e.key === 'Enter') void handleRenameItem(item.id); if (e.key === 'Escape') setEditingItemId(null) }} aria-label={t('common.rename')} className={`${ROW_INPUT} flex-1`} style={fs(12.5, 'body')} /> @@ -219,7 +220,7 @@ export default function PackingTemplateManager() { {/* Add category */} {addingCategory ? (
- setNewCatName(e.target.value)} + setNewCatName(e.target.value)} onKeyDown={e => { if (e.key === 'Enter') void handleAddCategory(); if (e.key === 'Escape') { setAddingCategory(false); setNewCatName('') } }} placeholder={t('admin.packingTemplates.categoryName')} className={COMPOSER_INPUT} style={fs(13, 'body')} /> diff --git a/client/src/components/Admin/SchoolHolidayCatalog.tsx b/client/src/components/Admin/SchoolHolidayCatalog.tsx index 849316232..39954895d 100644 --- a/client/src/components/Admin/SchoolHolidayCatalog.tsx +++ b/client/src/components/Admin/SchoolHolidayCatalog.tsx @@ -67,7 +67,7 @@ function Catalog() { }}>
- setName(event.target.value)} /> + setName(event.target.value)} /> setCode(event.target.value.toUpperCase())} placeholder="US" /> diff --git a/client/src/components/Admin/SchoolHolidayRegionEditor.tsx b/client/src/components/Admin/SchoolHolidayRegionEditor.tsx index 273ead59f..3c2001055 100644 --- a/client/src/components/Admin/SchoolHolidayRegionEditor.tsx +++ b/client/src/components/Admin/SchoolHolidayRegionEditor.tsx @@ -62,7 +62,7 @@ export default function SchoolHolidayRegionEditor({ region, busy, offline = fals
- setName(event.target.value)} /> + setName(event.target.value)} /> {t('schoolCatalog.periodHint')} {holidays.map((holiday, index) => { diff --git a/client/src/components/AtlasGlobe/AtlasGlobe.test.tsx b/client/src/components/AtlasGlobe/AtlasGlobe.test.tsx index bbf11c0a7..7f165fa84 100644 --- a/client/src/components/AtlasGlobe/AtlasGlobe.test.tsx +++ b/client/src/components/AtlasGlobe/AtlasGlobe.test.tsx @@ -17,6 +17,10 @@ const h = vi.hoisted(() => { insets: number[] = []; kicks = 0; disposed = false; + static create(opts: GlobeEngineOptions): FakeEngine { + return new FakeEngine(opts); + } + constructor(opts: GlobeEngineOptions) { if (state.failNext !== null) { const err = state.failNext; diff --git a/client/src/components/AtlasGlobe/AtlasGlobe.tsx b/client/src/components/AtlasGlobe/AtlasGlobe.tsx index 271d57ef9..2fddc88a4 100644 --- a/client/src/components/AtlasGlobe/AtlasGlobe.tsx +++ b/client/src/components/AtlasGlobe/AtlasGlobe.tsx @@ -54,7 +54,7 @@ const AtlasGlobe = forwardRef(function AtlasG if (!canvas) return; let engine: GlobeEngine; try { - engine = new GlobeEngine({ + engine = GlobeEngine.create({ canvas, fetchJson: (p) => propsRef.current.fetchJson(p), theme: globeTheme(propsRef.current.dark), diff --git a/client/src/components/AtlasGlobe/GlobeEngine.test.ts b/client/src/components/AtlasGlobe/GlobeEngine.test.ts index 81755681f..06bb56ed3 100644 --- a/client/src/components/AtlasGlobe/GlobeEngine.test.ts +++ b/client/src/components/AtlasGlobe/GlobeEngine.test.ts @@ -210,7 +210,7 @@ async function start(o: StartOptions = {}) { onSelect: vi.fn(), onFrame: vi.fn(), }; - const engine = new mod.GlobeEngine({ canvas, fetchJson, theme: o.theme ?? LIGHT, initial: o.initial, ...cb }); + const engine = mod.GlobeEngine.create({ canvas, fetchJson, theme: o.theme ?? LIGHT, initial: o.initial, ...cb }); engines.push(engine); return { mod, @@ -310,7 +310,7 @@ describe('GlobeEngine boot', () => { const otherFetch = vi.fn(async (): Promise => null); const canvas = document.createElement('canvas'); const onReady = vi.fn(); - const second = new first.mod.GlobeEngine({ canvas, fetchJson: otherFetch, theme: LIGHT, onReady }); + const second = first.mod.GlobeEngine.create({ canvas, fetchJson: otherFetch, theme: LIGHT, onReady }); engines.push(second); await flush(); expect(otherFetch).not.toHaveBeenCalled(); @@ -345,7 +345,7 @@ describe('GlobeEngine boot retries', () => { }); const onError = vi.fn(); engines.push( - new mod.GlobeEngine({ canvas: document.createElement('canvas'), fetchJson: fail, theme: LIGHT, onError }) + mod.GlobeEngine.create({ canvas: document.createElement('canvas'), fetchJson: fail, theme: LIGHT, onError }) ); const delays: number[] = []; for (let i = 0; i < 4; i++) { @@ -364,7 +364,7 @@ describe('GlobeEngine boot retries', () => { const ok = vi.fn(async (p: string): Promise => files[p]); const onReady = vi.fn(); engines.push( - new mod.GlobeEngine({ canvas: document.createElement('canvas'), fetchJson: ok, theme: LIGHT, onReady }) + mod.GlobeEngine.create({ canvas: document.createElement('canvas'), fetchJson: ok, theme: LIGHT, onReady }) ); await flush(); expect(ok).toHaveBeenCalledWith('manifest'); @@ -381,7 +381,9 @@ describe('GlobeEngine boot retries', () => { return files[p]; }); const onReady = vi.fn(); - engines.push(new mod.GlobeEngine({ canvas: document.createElement('canvas'), fetchJson, theme: LIGHT, onReady })); + engines.push( + mod.GlobeEngine.create({ canvas: document.createElement('canvas'), fetchJson, theme: LIGHT, onReady }) + ); await flush(); expect(pending.map((t) => t.ms)).toEqual([1000]); pending[0].cb(); diff --git a/client/src/components/AtlasGlobe/GlobeEngine.ts b/client/src/components/AtlasGlobe/GlobeEngine.ts index 5f9b205b9..7bed1952f 100644 --- a/client/src/components/AtlasGlobe/GlobeEngine.ts +++ b/client/src/components/AtlasGlobe/GlobeEngine.ts @@ -164,7 +164,13 @@ export class GlobeEngine { private sun: [number, number, number] = sunVector(new Date()); private sunAt = 0; - constructor(opts: GlobeEngineOptions) { + static create(opts: GlobeEngineOptions): GlobeEngine { + const engine = new GlobeEngine(opts); + void engine.boot(); + return engine; + } + + private constructor(opts: GlobeEngineOptions) { this.opts = opts; this.theme = opts.theme; Object.assign(this.cam, opts.initial ?? {}); @@ -187,7 +193,6 @@ export class GlobeEngine { this.resizeObs.observe(opts.canvas); opts.canvas.addEventListener('webglcontextlost', this.onContextLost); this.resize(); - void this.boot(); } // ---------------------------------------------------------------- loading diff --git a/client/src/components/AtlasGlobe/globeTheme.ts b/client/src/components/AtlasGlobe/globeTheme.ts index 496d37859..437faf4d7 100644 --- a/client/src/components/AtlasGlobe/globeTheme.ts +++ b/client/src/components/AtlasGlobe/globeTheme.ts @@ -14,7 +14,7 @@ export function hexToRgb(hex: string): Rgb { .map((c) => c + c) .join('') : h.slice(0, 6); - const n = parseInt(full, 16); + const n = Number.parseInt(full, 16); if (Number.isNaN(n)) return [0.5, 0.5, 0.5]; return [((n >> 16) & 255) / 255, ((n >> 8) & 255) / 255, (n & 255) / 255]; } diff --git a/client/src/components/Budget/CostsTable.tsx b/client/src/components/Budget/CostsTable.tsx index 574d01275..6c9bf5b2d 100644 --- a/client/src/components/Budget/CostsTable.tsx +++ b/client/src/components/Budget/CostsTable.tsx @@ -1,3 +1,4 @@ +import { focusRevealedEditor } from '../shared/dialogFocus' import { useMemo, useRef, useState, type KeyboardEvent, type ReactNode } from 'react' import { ChevronDown, Lock, Pencil, Plus, Trash2 } from 'lucide-react' import { useTranslation } from '../../i18n' @@ -307,7 +308,7 @@ function TextInput({ value, onSave, onCancel, label, numeric = false }: { if (ev.key === 'Escape') { ev.preventDefault(); ev.stopPropagation(); finish(onCancel) } } return ( - setDraft(ev.target.value)} onKeyDown={onKey} onBlur={() => finish(() => onSave(draft))} className={`${INPUT} ${numeric ? 'text-center tabular-nums' : ''}`} /> ) diff --git a/client/src/components/Budget/CostsToolbar.tsx b/client/src/components/Budget/CostsToolbar.tsx index 03cbe88ae..6af0e15fa 100644 --- a/client/src/components/Budget/CostsToolbar.tsx +++ b/client/src/components/Budget/CostsToolbar.tsx @@ -197,7 +197,7 @@ function FilterMenu(f: CostsFilterProps & { splitting: boolean }) { {open && ( -
{ if (e.key === 'Escape') close() }} className="absolute end-0 top-11 z-30" style={{ ...POPOVER, width: 310 }}> +
{ if (e.key === 'Escape') close() }} className="absolute end-0 top-11 z-30" style={{ ...POPOVER, width: 310 }}> {f.splitting && <>
{owners.map(([o, label]) => ( diff --git a/client/src/components/Collab/CollabLinks.tsx b/client/src/components/Collab/CollabLinks.tsx index 327aa5b60..2addf3b7b 100644 --- a/client/src/components/Collab/CollabLinks.tsx +++ b/client/src/components/Collab/CollabLinks.tsx @@ -1,3 +1,4 @@ +import { focusRevealedEditor } from '../shared/dialogFocus' import { cloneElement, CSSProperties, FormEvent, ReactElement, useEffect, useId, useRef, useState } from 'react' import { createPortal } from 'react-dom' import { ExternalLink, Link2, Pencil, Pin, Plus, Trash2, X } from 'lucide-react' @@ -147,7 +148,7 @@ function LinkModal({ link, onClose, onSave }: { link?: CollabLink; onClose: () =
- setTitle(e.target.value)} placeholder={t('collab.links.titlePlaceholder')} autoFocus style={field} /> + setTitle(e.target.value)} placeholder={t('collab.links.titlePlaceholder')} ref={focusRevealedEditor} style={field} />
diff --git a/client/src/components/Collab/CollabPolls.tsx b/client/src/components/Collab/CollabPolls.tsx index f42d84349..c7cd8163c 100644 --- a/client/src/components/Collab/CollabPolls.tsx +++ b/client/src/components/Collab/CollabPolls.tsx @@ -118,7 +118,7 @@ function CreatePollModal({ onClose, onCreate, t }: CreatePollModalProps) { )} > -