fix(editor): Task 4 round 1, swallow release, menu tests
This commit is contained in:
1 parent
ca5804a8b7
commit
dfc8965844
2 files changed
+80
-8
No files matched your search
@@ -54,7 +54,10 @@ function useMoreEscape(open: boolean, close: () => void) {
|
||||
}, [open, close])
|
||||
}
|
||||
|
||||
/** Swallows the click that completes a closing tap, once, so the page never sees it. */
|
||||
/**
|
||||
* Swallows the click that completes a closing tap, once, so the page never sees it. A press
|
||||
* that yields no click (cancelled, context menu, drag) releases it at once.
|
||||
*/
|
||||
function swallowNextClick() {
|
||||
const stop = (event: Event) => {
|
||||
event.stopPropagation()
|
||||
@@ -65,8 +68,12 @@ function swallowNextClick() {
|
||||
const release = () => {
|
||||
window.clearTimeout(timer)
|
||||
document.removeEventListener('click', stop, true)
|
||||
document.removeEventListener('pointercancel', release, true)
|
||||
document.removeEventListener('contextmenu', release, true)
|
||||
}
|
||||
document.addEventListener('click', stop, true)
|
||||
document.addEventListener('pointercancel', release, true)
|
||||
document.addEventListener('contextmenu', release, true)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user