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()
|
const root = useRoot()
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (Number(router.query.commentId) === Number(item.id)) {
|
|
||||||
ref.current.scrollIntoView()
|
|
||||||
ref.current.classList.add('flash-it')
|
|
||||||
router.replace({
|
|
||||||
pathname: router.pathname,
|
|
||||||
query: { id: router.query.id }
|
|
||||||
}, undefined, { scroll: false })
|
|
||||||
}
|
|
||||||
setCollapse(localStorage.getItem(`commentCollapse:${item.id}`) || collapse)
|
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)
|
||||||
|
}
|
||||||
}, [item])
|
}, [item])
|
||||||
|
|
||||||
const bottomedOut = depth === COMMENT_DEPTH_LIMIT
|
const bottomedOut = depth === COMMENT_DEPTH_LIMIT
|
||||||
|
|
Loading…
Reference in New Issue