added scroll to comment

This commit is contained in:
ingawei 2022-10-11 19:19:22 -07:00
parent b8a095d853
commit 141856fd1f
4 changed files with 15 additions and 24 deletions

View File

@ -158,7 +158,7 @@ export function CommentInputTextArea(props: {
attrs: { label: replyTo.username, id: replyTo.id },
})
.insertContent(' ')
.focus()
.focus(undefined, { scrollIntoView: false })
.run()
}
// eslint-disable-next-line react-hooks/exhaustive-deps

View File

@ -107,7 +107,6 @@ const CommentsTabContent = memo(function CommentsTabContent(props: {
onCancelAnswerResponse?: () => void
}) {
const { contract, answerResponse, onCancelAnswerResponse } = props
console.log(answerResponse)
const tips = useTipTxns({ contractId: contract.id })
const comments = useComments(contract.id) ?? props.comments
const [sort, setSort] = usePersistentState<'Newest' | 'Best'>('Newest', {
@ -175,16 +174,6 @@ const CommentsTabContent = memo(function CommentsTabContent(props: {
</Row>
)
// console.log('answer response:: ', answerResponse)
// sortedComments.map((comment, index) =>
// console.log(
// index,
// ',',
// comment.content.content[0].content[0].text,
// ':',
// dayjs(comment.createdTime).format('MM/DD/YY H:mm')
// )
// )
if (contract.outcomeType === 'FREE_RESPONSE') {
return (
<>

View File

@ -1,6 +1,6 @@
import clsx from 'clsx'
import { useRouter, NextRouter } from 'next/router'
import { ReactNode, useState } from 'react'
import { ReactNode, useEffect, useState } from 'react'
import { track } from '@amplitude/analytics-browser'
import { Col } from './col'
import { Tooltip } from 'web/components/tooltip'

View File

@ -1,4 +1,4 @@
import React, { memo, useEffect, useMemo, useState } from 'react'
import React, { memo, useEffect, useMemo, useRef, useState } from 'react'
import { ArrowLeftIcon } from '@heroicons/react/outline'
import dayjs from 'dayjs'
@ -209,11 +209,11 @@ export function ContractPageContent(
const [answerResponse, setAnswerResponse] = useState<Answer | undefined>(
undefined
)
const onAnswerCommentClick = useEvent((answer: Answer) => {
setAnswerResponse(answer)
answerRef.current.scrollIntoView({ behavior: 'smooth' })
})
const answerRef = useRef(null)
const onCancelAnswerResponse = useEvent(() => setAnswerResponse(undefined))
return (
@ -293,14 +293,16 @@ export function ContractPageContent(
userBets={userBets}
/>
<ContractTabs
contract={contract}
bets={bets}
userBets={userBets}
comments={comments}
answerResponse={answerResponse}
onCancelAnswerResponse={onCancelAnswerResponse}
/>
<div ref={answerRef}>
<ContractTabs
contract={contract}
bets={bets}
userBets={userBets}
comments={comments}
answerResponse={answerResponse}
onCancelAnswerResponse={onCancelAnswerResponse}
/>
</div>
</Col>
{!isCreator && <RecommendedContractsWidget contract={contract} />}
<ScrollToTopButton className="fixed bottom-16 right-2 z-20 lg:bottom-2 xl:hidden" />