Skip to content

Commit 3a01552

Browse files
committed
fix: pass onLinkPress to SelectableMarkdownText in FileMarkdownPreview
On iOS, FileMarkdownPreview rendered SelectableMarkdownText without onLinkPress, causing link taps to fall through to raw Linking.openURL instead of going through tryOpenExternalUrl. This left the iOS path without ExternalUrlOpenError logging and with unhandled rejections. Pass an onLinkPress callback that routes through tryOpenExternalUrl, consistent with how ThreadFeed already handles native markdown links.
1 parent aa8f9dc commit 3a01552

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

apps/mobile/src/features/files/FileMarkdownPreview.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useMemo } from "react";
1+
import { useCallback, useMemo } from "react";
22
import {
33
Markdown,
44
type CustomRenderers,
@@ -144,12 +144,19 @@ function useMarkdownPreviewStyles(): MarkdownPreviewStyles {
144144

145145
export function FileMarkdownPreview(props: { readonly markdown: string }) {
146146
const styles = useMarkdownPreviewStyles();
147+
const onLinkPress = useCallback((href: string) => {
148+
void tryOpenExternalUrl(href, "markdown-link");
149+
}, []);
147150

148151
return (
149152
<ScrollView className="flex-1 bg-card" contentContainerStyle={{ padding: 18 }}>
150153
<View className="mx-auto w-full max-w-[760px]">
151154
{hasNativeSelectableMarkdownText() ? (
152-
<SelectableMarkdownText markdown={props.markdown} textStyle={styles.nativeTextStyle} />
155+
<SelectableMarkdownText
156+
markdown={props.markdown}
157+
textStyle={styles.nativeTextStyle}
158+
onLinkPress={onLinkPress}
159+
/>
153160
) : (
154161
<Markdown
155162
options={{ gfm: true }}

0 commit comments

Comments
 (0)