ChatTextarea: pass ref to child

Fixes https://gitlab.com/soapbox-pub/soapbox/-/issues/1390
This commit is contained in:
Alex Gleason 2023-03-19 18:03:44 -05:00
parent 47561e5c01
commit 67ffe9609f
No known key found for this signature in database
GPG key ID: 7211D1F99744FBB7

View file

@ -14,13 +14,13 @@ interface IChatTextarea extends React.ComponentProps<typeof Textarea> {
} }
/** Custom textarea for chats. */ /** Custom textarea for chats. */
const ChatTextarea: React.FC<IChatTextarea> = ({ const ChatTextarea: React.FC<IChatTextarea> = React.forwardRef(({
attachments, attachments,
onDeleteAttachment, onDeleteAttachment,
uploadCount = 0, uploadCount = 0,
uploadProgress = 0, uploadProgress = 0,
...rest ...rest
}) => { }, ref) => {
const isUploading = uploadCount > 0; const isUploading = uploadCount > 0;
const handleDeleteAttachment = (i: number) => { const handleDeleteAttachment = (i: number) => {
@ -64,9 +64,9 @@ const ChatTextarea: React.FC<IChatTextarea> = ({
</HStack> </HStack>
)} )}
<Textarea theme='transparent' {...rest} /> <Textarea ref={ref} theme='transparent' {...rest} />
</div> </div>
); );
}; });
export default ChatTextarea; export default ChatTextarea;