diff --git a/ui/component/comment/view.jsx b/ui/component/comment/view.jsx index 6fac77383..56f64c5c4 100644 --- a/ui/component/comment/view.jsx +++ b/ui/component/comment/view.jsx @@ -117,6 +117,7 @@ function Comment(props: Props) { location: { pathname, search }, } = useHistory(); + const isLinkedComment = linkedCommentId && linkedCommentId === commentId; const isInLinkedCommentChain = linkedCommentId && linkedCommentAncestors[linkedCommentId] && @@ -205,6 +206,18 @@ function Comment(props: Props) { replace(`${pathname}?${urlParams.toString()}`); } + const linkedCommentRef = React.useCallback((node) => { + if (node !== null && window.pendingLinkedCommentScroll) { + const ROUGH_HEADER_HEIGHT = 125; // @see: --header-height + delete window.pendingLinkedCommentScroll; + window.scrollTo({ + top: node.getBoundingClientRect().top + window.scrollY - ROUGH_HEADER_HEIGHT, + left: 0, + behavior: 'smooth', + }); + } + }, []); + return (