From b75cedffd5b0683d45afe8a121c52cdf5b6adbfb Mon Sep 17 00:00:00 2001 From: "plebeius.eth" Date: Tue, 22 Aug 2023 11:49:04 +0200 Subject: [PATCH] fix void link for user address link --- src/components/ForwardRefLink.jsx | 13 +++++++++++-- src/components/Post.jsx | 2 +- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/components/ForwardRefLink.jsx b/src/components/ForwardRefLink.jsx index 2e579e72..d66c9b51 100644 --- a/src/components/ForwardRefLink.jsx +++ b/src/components/ForwardRefLink.jsx @@ -3,7 +3,16 @@ import { Link } from "react-router-dom"; const ForwardRefLink = React.forwardRef((props, ref) => { const { children, setRefAndCid, onMouseOver, onMouseLeave, onClick, ...otherProps } = props; - + + const handleClick = (event) => { + if (otherProps.to === "#void") { + event.preventDefault(); + } + if (onClick) { + onClick(event); + } + }; + useEffect(() => { if (ref.current && typeof setRefAndCid === 'function') { setRefAndCid(ref.current); @@ -16,7 +25,7 @@ const ForwardRefLink = React.forwardRef((props, ref) => { {...otherProps} onMouseOver={onMouseOver} onMouseLeave={onMouseLeave} - onClick={onClick} + onClick={handleClick} > {children} diff --git a/src/components/Post.jsx b/src/components/Post.jsx index 4d94e10c..16d3d6bd 100644 --- a/src/components/Post.jsx +++ b/src/components/Post.jsx @@ -74,7 +74,7 @@ const Post = ({ content, postQuoteOnClick, postQuoteOnOver, postQuoteOnLeave, po const linkTarget = matchedText.startsWith('u/') ? "_blank" : "_self"; if (matchedText.startsWith('u/')) { - linkTo = () => {}; + linkTo = "#void"; } else if (matchedText.startsWith('p/') || matchedText.startsWith('p/')) { linkTo = `/${matchedText}`; }