diff --git a/src/pages/catchup.jsx b/src/pages/catchup.jsx index 11759761..ff9df7ce 100644 --- a/src/pages/catchup.jsx +++ b/src/pages/catchup.jsx @@ -515,6 +515,36 @@ function Catchup() { authors, ]); + const prevSelectedAuthorMissing = useRef(false); + useEffect(() => { + console.log({ + prevSelectedAuthorMissing, + selectedAuthor, + authors, + }); + let timer; + if (selectedAuthor) { + if (authors[selectedAuthor]) { + if (prevSelectedAuthorMissing.current) { + timer = setTimeout(() => { + authorsListParent.current + .querySelector(`[data-author="${selectedAuthor}"]`) + ?.scrollIntoView({ + behavior: 'smooth', + inline: 'center', + }); + }, 500); + prevSelectedAuthorMissing.current = false; + } + } else { + prevSelectedAuthorMissing.current = true; + } + } + return () => { + clearTimeout(timer); + }; + }, [selectedAuthor, authors]); + return (
(