Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

fix(mobile): override the native iOS long-press menu on images (#6054)

Peter Chinman1e7beb912636
diff --git a/apps/web/src/features/channel/Message/ChannelMessage.tsx b/apps/web/src/features/channel/Message/ChannelMessage.tsx
index 3c6f1c2f85..15ff9fbd48 100644
--- a/apps/web/src/features/channel/Message/ChannelMessage.tsx
+++ b/apps/web/src/features/channel/Message/ChannelMessage.tsx
@@ -197,8 +197,6 @@ 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/apps/web/src/index.css b/apps/web/src/index.css
index 3cc27a8582..b2d5ee4eaf 100644
--- a/apps/web/src/index.css
+++ b/apps/web/src/index.css
@@ -539,6 +539,15 @@ html[data-theme-light='false'] {
user-select: text;
}
+ /* iOS answers a long-press on an image with its own callout ("Share", "Save
+ to Photos", "Copy"), which preempts the app's own long-press affordances
+ (e.g. the channel message action drawer). Suppress it everywhere; the
+ zero-specificity selector lets a component opt back in if it ever needs
+ the native menu. */
+ :where(img) {
+ -webkit-touch-callout: none;
+ }
+
:where(*) {
scrollbar-width: none;
}
diff --git a/apps/web/src/lib/core/directive/touchHandler.ts b/apps/web/src/lib/core/directive/touchHandler.ts
index a8fde6d15c..89c6794e0e 100644
--- a/apps/web/src/lib/core/directive/touchHandler.ts
+++ b/apps/web/src/lib/core/directive/touchHandler.ts
@@ -14,13 +14,6 @@ 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;
@@ -150,21 +143,6 @@ export function touchHandler(
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];