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(planner): guard the post-drag click swallow against a torn-down document

Mauricec4fbf039282e
diff --git a/client/src/utils/touchDragBridge.ts b/client/src/utils/touchDragBridge.ts
index 54ea57519..eda0b5ce8 100644
--- a/client/src/utils/touchDragBridge.ts
+++ b/client/src/utils/touchDragBridge.ts
@@ -192,7 +192,11 @@ function retarget(s: Session): void {
function swallowNextClick(): void {
const stop = (e: Event) => { e.stopPropagation(); e.preventDefault() }
document.addEventListener('click', stop, { capture: true, once: true })
- setTimeout(() => document.removeEventListener('click', stop, { capture: true }), 400)
+ // The fallback timer can outlive a torn-down jsdom in tests, where `document`
+ // is gone by the time it fires — hence the guard.
+ setTimeout(() => {
+ if (typeof document !== 'undefined') document.removeEventListener('click', stop, { capture: true })
+ }, 400)
}
/**