fix(planner): guard the post-drag click swallow against a torn-down document

This commit is contained in:
Maurice
2026-09-01 15:52:48 +02:00
committed by Maurice
parent 03bd5c77af
commit c4fbf03928
+5 -1
View File
@@ -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)
}
/**