diff --git a/src/components/Notes/NoteSubmit.tsx b/src/components/Notes/NoteSubmit.tsx index a77430e..44176bf 100644 --- a/src/components/Notes/NoteSubmit.tsx +++ b/src/components/Notes/NoteSubmit.tsx @@ -60,6 +60,10 @@ export const NoteSubmit = ({ }) }, [content, nsfw, setCache]) + useEffect(() => { + if (ref.current) adjustTextareaHeight(ref.current) + }, [content]) + const [showTryAgainPopup, setShowTryAgainPopup] = useState(false) useEffect(() => { const isTimeout = actionData?.type === 'timeout' @@ -85,6 +89,8 @@ export const NoteSubmit = ({ setContent('') setNsfw(false) + setShowPreview(false) + submit(JSON.stringify(formSubmit), { method: 'post', encType: 'application/json', @@ -103,10 +109,6 @@ export const NoteSubmit = ({ // Cancel if not confirmed if (!confirm) return - // Reset form - setContent('') - setNsfw(false) - handleFormSubmit() }, [handleFormSubmit] @@ -115,7 +117,6 @@ export const NoteSubmit = ({ event: React.ChangeEvent ) => { setContent(event.currentTarget.value) - adjustTextareaHeight(event.currentTarget) } const handlePreviewToggle = () => { diff --git a/src/components/comment/CommentsPopup.tsx b/src/components/comment/CommentsPopup.tsx index 014a1bf..1bc691f 100644 --- a/src/components/comment/CommentsPopup.tsx +++ b/src/components/comment/CommentsPopup.tsx @@ -7,7 +7,14 @@ import { useReplies } from 'hooks' import { nip19 } from 'nostr-tools' -import { ChangeEvent, useCallback, useEffect, useMemo, useState } from 'react' +import { + ChangeEvent, + useCallback, + useEffect, + useMemo, + useRef, + useState +} from 'react' import { Link, useLoaderData, @@ -96,16 +103,19 @@ export const CommentsPopup = ({ title }: CommentsPopupProps) => { ) const navigate = useNavigate() - + const ref = useRef(null) const [isSubmitting, setIsSubmitting] = useState(false) const [replyText, setReplyText] = useState('') const handleChange = useCallback((e: ChangeEvent) => { const value = e.currentTarget.value setReplyText(value) - adjustTextareaHeight(e.currentTarget) }, []) + useEffect(() => { + if (ref.current) adjustTextareaHeight(ref.current) + }, [replyText]) + const [visible, setVisible] = useState([]) const discoveredCount = commentEvents.length - visible.length const [isLoading, setIsLoading] = useState(true) @@ -430,6 +440,7 @@ export const CommentsPopup = ({ title }: CommentsPopupProps) => {