Skip to content

Commit

Permalink
fix: not scrolling problem
Browse files Browse the repository at this point in the history
  • Loading branch information
CaliCastle committed Jun 6, 2023
1 parent bd83941 commit 0b6cba9
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions components/Commentable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,15 @@ function Root({ className, blockId }: CommentableProps) {
const formRef = React.useRef<HTMLFormElement>(null)
const commentsRef = React.useRef<HTMLUListElement>(null)
const scrollToComment = React.useCallback((id: string) => {
if (commentsRef.current) {
commentsRef.current
.querySelector(`[data-commentid="${id}"]`)
?.scrollIntoView({
behavior: 'smooth',
})
}
setTimeout(() => {
if (commentsRef.current) {
commentsRef.current
.querySelector(`[data-commentid="${id}"]`)
?.scrollIntoView({
behavior: 'smooth',
})
}
}, 300)
}, [])

const { mutate: createComment, isLoading } = useMutation(
Expand Down

0 comments on commit 0b6cba9

Please sign in to comment.