Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
fix: block message long-press when touch originates on an image (#3990)
Peter Chinmanf42896578932
diff --git a/js/app/packages/channel/Message/ChannelMessage.tsx b/js/app/packages/channel/Message/ChannelMessage.tsxindex 5ca19c1530..43edf66478 100644--- a/js/app/packages/channel/Message/ChannelMessage.tsx+++ b/js/app/packages/channel/Message/ChannelMessage.tsx@@ -191,6 +191,8 @@ export function ChannelMessage(props: ChannelMessageProps) {ref={(el) =>touchHandler(el, () => ({touchClassName: 'channel-message-long-press-highlight',+ // Yield to the native image callout when long-pressing an image.+ skipSelectors: ['img'],onLongPress: () => drawerManager?.open(props.message, props.actions),}))}diff --git a/js/app/packages/core/directive/touchHandler.ts b/js/app/packages/core/directive/touchHandler.tsindex e61112dd3a..a8fde6d15c 100644--- a/js/app/packages/core/directive/touchHandler.ts+++ b/js/app/packages/core/directive/touchHandler.ts@@ -14,6 +14,13 @@ interface TouchHandlerOptions {delay?: number;moveThreshold?: number;stopTouchStartPropagation?: boolean;+ /**+ * Selectors for which our touch handling should be skipped entirely when the+ * touch originates on a matching element (or one of its ancestors). Useful to+ * avoid competing with native behavior, e.g. `['img']` so a long-press on an+ * image yields to the native image callout.+ */+ skipSelectors?: string[];/** CSS class added while the touch highlight is active. */touchClassName?: string;touchClassEnterDelay?: number;@@ -142,6 +149,22 @@ export function touchHandler(setValidShortTouch(false);return;}++ // Skip our touch handling when the touch originates on an opted-out element+ // so it doesn't compete with native behavior (e.g. `['img']` yields to the+ // native image callout).+ const skipSelectors = options().skipSelectors;+ if (+ skipSelectors?.length &&+ (e.target as Element)?.closest(skipSelectors.join(','))+ ) {+ clearState();+ cancelTouchClassEnter();+ endTouchClass();+ setValidShortTouch(false);+ return;+ }+initStateForNewTouch();const touch = e.touches[0];