From 7759f64fede7558941b4c1a0f1ab6e1011814152 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?marcin=20miko=C5=82ajczak?= Date: Sun, 12 Feb 2023 22:23:44 +0100 Subject: [PATCH] Chats: reset chat message field height after sending a message MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: marcin mikołajczak --- CHANGELOG.md | 1 + app/soapbox/features/chats/components/chat-composer.tsx | 5 ++++- app/soapbox/features/chats/components/chat.tsx | 3 +++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 438306e1f..3b56934c1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Groups: Initial support for groups. - Profile: Add RSS link to user profiles. - Reactions: adds support for reacting to chat messages. +- Chats: reset chat message field height after sending a message. ### Changed - Chats: improved display of media attachments. diff --git a/app/soapbox/features/chats/components/chat-composer.tsx b/app/soapbox/features/chats/components/chat-composer.tsx index 165e7ce9d..23a531d69 100644 --- a/app/soapbox/features/chats/components/chat-composer.tsx +++ b/app/soapbox/features/chats/components/chat-composer.tsx @@ -42,6 +42,7 @@ interface IChatComposer extends Pick void resetFileKey: number | null + resetContentKey: number | null attachments?: Attachment[] onDeleteAttachment?: () => void isUploading?: boolean @@ -58,6 +59,7 @@ const ChatComposer = React.forwardRef disabled = false, onSelectFile, resetFileKey, + resetContentKey, onPaste, attachments = [], onDeleteAttachment, @@ -179,6 +181,7 @@ const ChatComposer = React.forwardRef ); }); -export default ChatComposer; \ No newline at end of file +export default ChatComposer; diff --git a/app/soapbox/features/chats/components/chat.tsx b/app/soapbox/features/chats/components/chat.tsx index 55b0cf2cb..6610cfa00 100644 --- a/app/soapbox/features/chats/components/chat.tsx +++ b/app/soapbox/features/chats/components/chat.tsx @@ -54,6 +54,7 @@ const Chat: React.FC = ({ chat, inputRef, className }) => { const [attachment, setAttachment] = useState(undefined); const [isUploading, setIsUploading] = useState(false); const [uploadProgress, setUploadProgress] = useState(0); + const [resetContentKey, setResetContentKey] = useState(fileKeyGen()); const [resetFileKey, setResetFileKey] = useState(fileKeyGen()); const [errorMessage, setErrorMessage] = useState(); @@ -83,6 +84,7 @@ const Chat: React.FC = ({ chat, inputRef, className }) => { setIsUploading(false); setUploadProgress(0); setResetFileKey(fileKeyGen()); + setResetContentKey(fileKeyGen()); }; const sendMessage = () => { @@ -171,6 +173,7 @@ const Chat: React.FC = ({ chat, inputRef, className }) => { errorMessage={errorMessage} onSelectFile={handleFiles} resetFileKey={resetFileKey} + resetContentKey={resetContentKey} onPaste={handlePaste} attachments={attachment ? [attachment] : []} onDeleteAttachment={handleRemoveFile}