From 427ed60274f2fb7a7a24fe52c04ed95c8f10bd8e Mon Sep 17 00:00:00 2001 From: Claire Date: Thu, 12 Sep 2024 22:42:07 +0200 Subject: [PATCH] Fix link handling within detailed status contents --- .../status/components/detailed_status.tsx | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/app/javascript/flavours/glitch/features/status/components/detailed_status.tsx b/app/javascript/flavours/glitch/features/status/components/detailed_status.tsx index 0c2a20a531..a4e7fccf9a 100644 --- a/app/javascript/flavours/glitch/features/status/components/detailed_status.tsx +++ b/app/javascript/flavours/glitch/features/status/components/detailed_status.tsx @@ -19,6 +19,7 @@ import { getHashtagBarForStatus } from 'flavours/glitch/components/hashtag_bar'; import { IconLogo } from 'flavours/glitch/components/logo'; import { Permalink } from 'flavours/glitch/components/permalink'; import PictureInPicturePlaceholder from 'flavours/glitch/components/picture_in_picture_placeholder'; +import { useAppHistory } from 'flavours/glitch/components/router'; import { VisibilityIcon } from 'flavours/glitch/components/visibility_icon'; import { useAppSelector } from 'flavours/glitch/store'; @@ -71,6 +72,7 @@ export const DetailedStatus: React.FC<{ const properStatus = status?.get('reblog') ?? status; const [height, setHeight] = useState(0); const nodeRef = useRef(); + const history = useAppHistory(); const rewriteMentions = useAppSelector( (state) => state.local_settings.get('rewrite_mentions', false) as boolean, @@ -137,6 +139,18 @@ export const DetailedStatus: React.FC<{ if (onTranslate) onTranslate(status); }, [onTranslate, status]); + const parseClick = useCallback( + (e: React.MouseEvent, destination: string) => { + if (e.button === 0 && !(e.ctrlKey || e.altKey || e.metaKey)) { + e.preventDefault(); + history.push(destination); + } + + e.stopPropagation(); + }, + [history], + ); + if (!properStatus) { return null; } @@ -354,7 +368,6 @@ export const DetailedStatus: React.FC<{ )} - {/* TODO: parseClick={this.parseClick} */}