mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-10-18 21:16:47 +00:00
fix(planner): guard the post-drag click swallow against a torn-down document
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user