diff --git a/src/components/views/Board.jsx b/src/components/views/Board.jsx index aeb8aed4..d6d6a3cd 100644 --- a/src/components/views/Board.jsx +++ b/src/components/views/Board.jsx @@ -384,7 +384,7 @@ const Board = () => {
-
+

{commentMediaInfo?.url ? ( @@ -650,7 +650,7 @@ const Board = () => {

-
+
diff --git a/src/components/views/Thread.jsx b/src/components/views/Thread.jsx index b78751d1..3c2cdef5 100644 --- a/src/components/views/Thread.jsx +++ b/src/components/views/Thread.jsx @@ -402,7 +402,7 @@ const Thread = () => { <>
-
+
{commentMediaInfo?.url ? (
@@ -616,9 +616,6 @@ const Thread = () => { {}} className="quote-link" onClick={(event) => { handleQuoteClick(reply, shortParentCid, comment.shortCid, event); - if (shortParentCid === comment.shortCid) { - window.scrollTo(0, 0); - } }} > {`c/${shortParentCid}`}{shortParentCid === comment.shortCid ? " (OP)" : null} @@ -634,7 +631,7 @@ const Thread = () => {

-
+
diff --git a/src/utils/handleQuoteClick.js b/src/utils/handleQuoteClick.js index c450a7c3..0eaa7065 100644 --- a/src/utils/handleQuoteClick.js +++ b/src/utils/handleQuoteClick.js @@ -1,6 +1,7 @@ function handleQuoteClick(reply, parentCid, threadCid) { const cid = parentCid ? parentCid : reply.shortCid; const isMobile = window.innerWidth <= 480; + const postNumberSelector = isMobile ? '.post-number-mobile' : '.post-number-desktop'; if (threadCid && cid === threadCid) { const highlightedElements = document.querySelectorAll('.highlighted'); @@ -9,11 +10,24 @@ function handleQuoteClick(reply, parentCid, threadCid) { el.classList.remove('highlighted'); }); + const opElementSelector = isMobile ? '.op-mobile' : '.op-desktop'; + + const opElement = [...document.querySelectorAll(opElementSelector)] + .find(el => { + const postNumberElement = el.querySelector(postNumberSelector); + return postNumberElement && postNumberElement.innerHTML.includes(threadCid); + }); + + if (opElement) { + opElement.scrollIntoView({ behavior: "auto", block: "start" }); + } else { + console.log('Could not find OP element'); + } + return; } - const targetElementSelector = isMobile ? '.post-reply-mobile' : '.post-reply-desktop'; - const postNumberSelector = isMobile ? '.post-number-mobile' : '.post-number-desktop'; + const targetElementSelector = isMobile ? '.post-reply-mobile, .op-mobile' : '.post-reply-desktop, .op-desktop'; const targetElement = [...document.querySelectorAll(targetElementSelector)] .find(el => { @@ -28,8 +42,11 @@ function handleQuoteClick(reply, parentCid, threadCid) { el.classList.remove('highlighted'); }); - targetElement.scrollIntoView({ behavior: "auto", block: "center" }); - targetElement.classList.add('highlighted'); + targetElement.scrollIntoView({ behavior: "auto", block: "start" }); + + if (!targetElement.classList.contains('op-mobile') && !targetElement.classList.contains('op-desktop')) { + targetElement.classList.add('highlighted'); + } } else { console.log('Could not find target element');