fix(notes): reset preview and size after publishing
All checks were successful
Release to Staging / build_and_release (push) Successful in 1m8s

This commit is contained in:
en 2025-02-25 12:47:02 +01:00
parent 7cfd944abf
commit 88725da491
2 changed files with 20 additions and 8 deletions

View File

@ -60,6 +60,10 @@ export const NoteSubmit = ({
})
}, [content, nsfw, setCache])
useEffect(() => {
if (ref.current) adjustTextareaHeight(ref.current)
}, [content])
const [showTryAgainPopup, setShowTryAgainPopup] = useState<boolean>(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<HTMLTextAreaElement>
) => {
setContent(event.currentTarget.value)
adjustTextareaHeight(event.currentTarget)
}
const handlePreviewToggle = () => {

View File

@ -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<HTMLTextAreaElement>(null)
const [isSubmitting, setIsSubmitting] = useState(false)
const [replyText, setReplyText] = useState('')
const handleChange = useCallback((e: ChangeEvent<HTMLTextAreaElement>) => {
const value = e.currentTarget.value
setReplyText(value)
adjustTextareaHeight(e.currentTarget)
}, [])
useEffect(() => {
if (ref.current) adjustTextareaHeight(ref.current)
}, [replyText])
const [visible, setVisible] = useState<CommentEvent[]>([])
const discoveredCount = commentEvents.length - visible.length
const [isLoading, setIsLoading] = useState(true)
@ -430,6 +440,7 @@ export const CommentsPopup = ({ title }: CommentsPopupProps) => {
<div className='pUMCB_CommentToPrime'>
<div className='IBMSMSMBSSCC_Top'>
<textarea
ref={ref}
className='IBMSMSMBSSCC_Top_Box postSocialTextarea'
placeholder='Got something to say?'
value={replyText}