wait for comments to collapse before scrolling
This commit is contained in:
parent
ab3b24a072
commit
5958875f1e
|
@ -99,15 +99,18 @@ export default function Comment ({
|
|||
const root = useRoot()
|
||||
|
||||
useEffect(() => {
|
||||
setCollapse(localStorage.getItem(`commentCollapse:${item.id}`) || collapse)
|
||||
if (Number(router.query.commentId) === Number(item.id)) {
|
||||
// HACK wait for other comments to collapse if they're collapsed
|
||||
setTimeout(() => {
|
||||
ref.current.scrollIntoView()
|
||||
ref.current.classList.add('flash-it')
|
||||
router.replace({
|
||||
pathname: router.pathname,
|
||||
query: { id: router.query.id }
|
||||
}, undefined, { scroll: false })
|
||||
}, 20)
|
||||
}
|
||||
setCollapse(localStorage.getItem(`commentCollapse:${item.id}`) || collapse)
|
||||
}, [item])
|
||||
|
||||
const bottomedOut = depth === COMMENT_DEPTH_LIMIT
|
||||
|
|
Loading…
Reference in New Issue