From f900ae285c9805577d4c54d45c058bc6a5a04566 Mon Sep 17 00:00:00 2001 From: Alexander Zinchuk Date: Sun, 23 Jul 2023 10:08:02 +0200 Subject: [PATCH] Chat List: Fix context menu being stuck on tap --- src/hooks/useContextMenuHandlers.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/hooks/useContextMenuHandlers.ts b/src/hooks/useContextMenuHandlers.ts index 944a6415e..aedca2084 100644 --- a/src/hooks/useContextMenuHandlers.ts +++ b/src/hooks/useContextMenuHandlers.ts @@ -95,14 +95,14 @@ const useContextMenuHandlers = ( } // Temporarily intercept and clear the next click - element.addEventListener('touchend', (e) => { + document.addEventListener('touchend', (e) => { // On iOS in PWA mode, the context menu may cause click-through to the element in the menu upon opening if (IS_IOS && IS_PWA) { setTimeout(() => { - element.removeEventListener('mousedown', stopEvent, { + document.removeEventListener('mousedown', stopEvent, { capture: true, }); - element.removeEventListener('click', stopEvent, { + document.removeEventListener('click', stopEvent, { capture: true, }); }, IOS_PWA_CONTEXT_MENU_DELAY_MS); @@ -115,11 +115,11 @@ const useContextMenuHandlers = ( // On iOS15, in PWA mode, the context menu immediately closes after opening if (IS_PWA && IS_IOS) { - element.addEventListener('mousedown', stopEvent, { + document.addEventListener('mousedown', stopEvent, { once: true, capture: true, }); - element.addEventListener('click', stopEvent, { + document.addEventListener('click', stopEvent, { once: true, capture: true, });