diff --git a/src/components/reply-modal/reply-modal.tsx b/src/components/reply-modal/reply-modal.tsx index ebff5faa..86c66a54 100644 --- a/src/components/reply-modal/reply-modal.tsx +++ b/src/components/reply-modal/reply-modal.tsx @@ -13,9 +13,10 @@ import _ from 'lodash'; interface ReplyModalProps { closeModal: () => void; parentCid: string; + scrollY: number; } -const ReplyModal = ({ closeModal, parentCid }: ReplyModalProps) => { +const ReplyModal = ({ closeModal, parentCid, scrollY }: ReplyModalProps) => { const { t } = useTranslation(); const { subplebbitAddress } = useParams() as { subplebbitAddress: string }; const { setContent, resetContent, replyIndex, publishReply } = useReply({ cid: parentCid, subplebbitAddress }); @@ -56,12 +57,11 @@ const ReplyModal = ({ closeModal, parentCid }: ReplyModalProps) => { useEffect(() => { if (nodeRef.current && isMobile) { const viewportHeight = window.innerHeight; - const scrollY = window.scrollY; const modalHeight = 150; const centeredPosition = scrollY + viewportHeight / 2 - modalHeight / 2; nodeRef.current.style.top = `${centeredPosition}px`; } - }, [isMobile]); + }, [isMobile, scrollY]); const modalContent = (