fix: Comment sidebar should not overtake scrolling if linked to anchor, closes #8296

This commit is contained in:
Tom Moor committed 2025-01-25 11:44:38 -05:00
1 parent 500730b243
commit dfe97bee50
1 file changed
+3 -3
@@ -54,7 +54,7 @@ function CommentThread({
collapseThreshold = 5,
collapseNumDisplayed = 3,
}: Props) {
const [focusedOnMount] = React.useState(focused);
const [scrollOnMount] = React.useState(focused && !window.location.hash);
const { editor } = useDocumentContext();
const { comments } = useStores();
const topRef = React.useRef<HTMLDivElement>(null);
@@ -165,7 +165,7 @@ function CommentThread({
React.useEffect(() => {
if (focused) {
if (focusedOnMount) {
if (scrollOnMount) {
setTimeout(() => {
if (!topRef.current) {
return;
@@ -209,7 +209,7 @@ function CommentThread({
isMarkVisible ? 0 : sidebarAppearDuration
);
}
}, [focused, focusedOnMount, thread.id]);
}, [focused, scrollOnMount, thread.id]);
return (
<Thread