Skip to content

Commit

Permalink
Fix pr #5677: Fix issue #5676: [Bug]: Frontend Hyperlink in Chat wind…
Browse files Browse the repository at this point in the history
…ow should open link in a new tab
  • Loading branch information
openhands-agent committed Dec 18, 2024
1 parent 508468c commit 8b7033f
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions frontend/src/components/features/chat/chat-message.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<a href={href} target="_blank" rel="noopener noreferrer">
{linkChildren}
</a>
);
}

interface ChatMessageProps {
type: "user" | "assistant";
message: string;
Expand Down Expand Up @@ -62,11 +76,7 @@ export function ChatMessage({
code,
ul,
ol,
a: ({ href, children }) => (
<a href={href} target="_blank" rel="noopener noreferrer">
{children}
</a>
),
a: MarkdownLink,
}}
remarkPlugins={[remarkGfm]}
>
Expand Down

0 comments on commit 8b7033f

Please sign in to comment.