From 752d9a4df7f5da7d12f89fccf7a2ffc3ad2ad955 Mon Sep 17 00:00:00 2001 From: Alexander Zinchuk Date: Mon, 26 Jul 2021 17:36:01 +0300 Subject: [PATCH] Message Context Menu: Open system menu for links on mobiles (#1325) --- src/hooks/useContextMenuHandlers.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/hooks/useContextMenuHandlers.ts b/src/hooks/useContextMenuHandlers.ts index c4c3b530e..0d3fc11c5 100644 --- a/src/hooks/useContextMenuHandlers.ts +++ b/src/hooks/useContextMenuHandlers.ts @@ -89,9 +89,9 @@ export default ( const emulateContextMenuEvent = (originalEvent: TouchEvent) => { clearLongPressTimer(); - const { clientX, clientY } = originalEvent.touches[0]; + const { clientX, clientY, target } = originalEvent.touches[0]; - if (contextMenuPosition) { + if (contextMenuPosition || (shouldDisableOnLink && (target as HTMLElement).matches('a.text-entity-link[href]'))) { return; } @@ -130,7 +130,7 @@ export default ( element.removeEventListener('touchend', clearLongPressTimer, true); element.removeEventListener('touchmove', clearLongPressTimer); }; - }, [contextMenuPosition, isMenuDisabled, shouldDisableOnLongTap, elementRef]); + }, [contextMenuPosition, isMenuDisabled, shouldDisableOnLongTap, elementRef, shouldDisableOnLink]); return { isContextMenuOpen,