From 8b7033f9b14957da8c570b245d5c28d2bf69a57e Mon Sep 17 00:00:00 2001 From: openhands Date: Wed, 18 Dec 2024 20:02:04 +0000 Subject: [PATCH] Fix pr #5677: Fix issue #5676: [Bug]: Frontend Hyperlink in Chat window should open link in a new tab --- .../components/features/chat/chat-message.tsx | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/frontend/src/components/features/chat/chat-message.tsx b/frontend/src/components/features/chat/chat-message.tsx index 89e1aae336d0..da4f68fefbb4 100644 --- a/frontend/src/components/features/chat/chat-message.tsx +++ b/frontend/src/components/features/chat/chat-message.tsx @@ -6,6 +6,20 @@ import { cn } from "#/utils/utils"; import { ul, ol } from "../markdown/list"; import { CopyToClipboardButton } from "#/components/shared/buttons/copy-to-clipboard-button"; +function MarkdownLink({ + href, + children: linkChildren, +}: { + href?: string; + children: React.ReactNode; +}) { + return ( + + {linkChildren} + + ); +} + interface ChatMessageProps { type: "user" | "assistant"; message: string; @@ -62,11 +76,7 @@ export function ChatMessage({ code, ul, ol, - a: ({ href, children }) => ( - - {children} - - ), + a: MarkdownLink, }} remarkPlugins={[remarkGfm]} >