mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
fix(backlinks): scroll to reply and persist highlight when clicking OP backlink
This commit is contained in:
@@ -71,6 +71,15 @@ const scrollToThreadCardTop = (threadCid: string) => {
|
|||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const scrollToReplyOnPage = (cid: string) => {
|
||||||
|
const el = document.querySelector<HTMLElement>(`[data-cid="${cid}"][data-post-cid]`);
|
||||||
|
if (!el) return false;
|
||||||
|
el.scrollIntoView({ behavior: 'smooth', block: 'center' });
|
||||||
|
el.classList.add('scroll-highlight');
|
||||||
|
setTimeout(() => el.classList.remove('scroll-highlight'), 2000);
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
|
||||||
const DesktopQuotePreview = ({ backlinkReply, quotelinkReply, isBacklinkReply, isQuotelinkReply, isOP, showTrailingBreak = true }: ReplyQuotePreviewProps) => {
|
const DesktopQuotePreview = ({ backlinkReply, quotelinkReply, isBacklinkReply, isQuotelinkReply, isOP, showTrailingBreak = true }: ReplyQuotePreviewProps) => {
|
||||||
const [hoveredCid, setHoveredCid] = useState<string | null>(null);
|
const [hoveredCid, setHoveredCid] = useState<string | null>(null);
|
||||||
const [outOfViewCid, setOutOfViewCid] = useState<string | null>(null);
|
const [outOfViewCid, setOutOfViewCid] = useState<string | null>(null);
|
||||||
@@ -126,6 +135,7 @@ const DesktopQuotePreview = ({ backlinkReply, quotelinkReply, isBacklinkReply, i
|
|||||||
scrollToThreadCardTop(cid);
|
scrollToThreadCardTop(cid);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (scrollToReplyOnPage(cid)) return;
|
||||||
navigate(threadRoute);
|
navigate(threadRoute);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -242,6 +252,7 @@ const MobileQuotePreview = ({ backlinkReply, quotelinkReply, isBacklinkReply, is
|
|||||||
scrollToThreadCardTop(cid);
|
scrollToThreadCardTop(cid);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (scrollToReplyOnPage(cid)) return;
|
||||||
navigate(threadRoute);
|
navigate(threadRoute);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
+4
-2
@@ -82,7 +82,8 @@ hr {
|
|||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
.highlight {
|
.highlight,
|
||||||
|
.scroll-highlight {
|
||||||
background: var(--reply-highlight-background-color) !important;
|
background: var(--reply-highlight-background-color) !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -104,7 +105,8 @@ hr {
|
|||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
.highlight {
|
.highlight,
|
||||||
|
.scroll-highlight {
|
||||||
background: var(--reply-highlight-background-color) !important;
|
background: var(--reply-highlight-background-color) !important;
|
||||||
border: var(--reply-highlight-border) !important;
|
border: var(--reply-highlight-border) !important;
|
||||||
border-left: var(--reply-highlight-border-left, revert) !important;
|
border-left: var(--reply-highlight-border-left, revert) !important;
|
||||||
|
|||||||
Reference in New Issue
Block a user