From c4fbf039282eda27912d074a06910e807c2f191b Mon Sep 17 00:00:00 2001 From: Maurice Date: Tue, 1 Sep 2026 15:52:48 +0200 Subject: [PATCH] fix(planner): guard the post-drag click swallow against a torn-down document --- client/src/utils/touchDragBridge.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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) } /**