1
0
Fork 0
mirror of https://github.com/muerwre/vault-frontend.git synced 2025-04-25 12:56:41 +07:00

fixed ref forwarding on textareas

This commit is contained in:
Fedor Katurov 2022-01-05 16:32:07 +07:00
parent 2b7b756212
commit 140e36b6b7
5 changed files with 58 additions and 44 deletions

View file

@ -25,7 +25,7 @@ interface IProps {
}
const CommentForm: FC<IProps> = ({ comment, nodeId, saveComment, onCancelEdit }) => {
const [textarea, setTextarea] = useState<HTMLTextAreaElement>();
const [textarea, setTextArea] = useState<HTMLTextAreaElement | null>(null);
const uploader = useFileUploader(
UPLOAD_SUBJECTS.COMMENT,
UPLOAD_TARGETS.COMMENTS,
@ -55,7 +55,7 @@ const CommentForm: FC<IProps> = ({ comment, nodeId, saveComment, onCancelEdit })
}, [formik]);
const error = formik.status || formik.errors.text;
useInputPasteUpload(textarea, uploader.uploadFiles);
const onPaste = useInputPasteUpload(uploader.uploadFiles);
return (
<UploadDropzone onUpload={uploader.uploadFiles}>
@ -63,7 +63,7 @@ const CommentForm: FC<IProps> = ({ comment, nodeId, saveComment, onCancelEdit })
<FormikProvider value={formik}>
<FileUploaderProvider value={uploader}>
<div className={styles.input}>
<LocalCommentFormTextarea setRef={setTextarea} />
<LocalCommentFormTextarea onPaste={onPaste} ref={setTextArea} />
{!!error && (
<div className={styles.error} onClick={clearError}>