Chats: reset chat message field height after sending a message
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
parent
380d2b763f
commit
7759f64fed
3 changed files with 8 additions and 1 deletions
|
@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
- Groups: Initial support for groups.
|
- Groups: Initial support for groups.
|
||||||
- Profile: Add RSS link to user profiles.
|
- Profile: Add RSS link to user profiles.
|
||||||
- Reactions: adds support for reacting to chat messages.
|
- Reactions: adds support for reacting to chat messages.
|
||||||
|
- Chats: reset chat message field height after sending a message.
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
- Chats: improved display of media attachments.
|
- Chats: improved display of media attachments.
|
||||||
|
|
|
@ -42,6 +42,7 @@ interface IChatComposer extends Pick<React.TextareaHTMLAttributes<HTMLTextAreaEl
|
||||||
errorMessage: string | undefined
|
errorMessage: string | undefined
|
||||||
onSelectFile: (files: FileList, intl: IntlShape) => void
|
onSelectFile: (files: FileList, intl: IntlShape) => void
|
||||||
resetFileKey: number | null
|
resetFileKey: number | null
|
||||||
|
resetContentKey: number | null
|
||||||
attachments?: Attachment[]
|
attachments?: Attachment[]
|
||||||
onDeleteAttachment?: () => void
|
onDeleteAttachment?: () => void
|
||||||
isUploading?: boolean
|
isUploading?: boolean
|
||||||
|
@ -58,6 +59,7 @@ const ChatComposer = React.forwardRef<HTMLTextAreaElement | null, IChatComposer>
|
||||||
disabled = false,
|
disabled = false,
|
||||||
onSelectFile,
|
onSelectFile,
|
||||||
resetFileKey,
|
resetFileKey,
|
||||||
|
resetContentKey,
|
||||||
onPaste,
|
onPaste,
|
||||||
attachments = [],
|
attachments = [],
|
||||||
onDeleteAttachment,
|
onDeleteAttachment,
|
||||||
|
@ -179,6 +181,7 @@ const ChatComposer = React.forwardRef<HTMLTextAreaElement | null, IChatComposer>
|
||||||
<Stack grow>
|
<Stack grow>
|
||||||
<Combobox onSelect={onSelectComboboxOption}>
|
<Combobox onSelect={onSelectComboboxOption}>
|
||||||
<ComboboxInput
|
<ComboboxInput
|
||||||
|
key={resetContentKey}
|
||||||
as={ChatTextarea}
|
as={ChatTextarea}
|
||||||
autoFocus
|
autoFocus
|
||||||
ref={ref}
|
ref={ref}
|
||||||
|
|
|
@ -54,6 +54,7 @@ const Chat: React.FC<ChatInterface> = ({ chat, inputRef, className }) => {
|
||||||
const [attachment, setAttachment] = useState<any>(undefined);
|
const [attachment, setAttachment] = useState<any>(undefined);
|
||||||
const [isUploading, setIsUploading] = useState(false);
|
const [isUploading, setIsUploading] = useState(false);
|
||||||
const [uploadProgress, setUploadProgress] = useState(0);
|
const [uploadProgress, setUploadProgress] = useState(0);
|
||||||
|
const [resetContentKey, setResetContentKey] = useState<number>(fileKeyGen());
|
||||||
const [resetFileKey, setResetFileKey] = useState<number>(fileKeyGen());
|
const [resetFileKey, setResetFileKey] = useState<number>(fileKeyGen());
|
||||||
const [errorMessage, setErrorMessage] = useState<string>();
|
const [errorMessage, setErrorMessage] = useState<string>();
|
||||||
|
|
||||||
|
@ -83,6 +84,7 @@ const Chat: React.FC<ChatInterface> = ({ chat, inputRef, className }) => {
|
||||||
setIsUploading(false);
|
setIsUploading(false);
|
||||||
setUploadProgress(0);
|
setUploadProgress(0);
|
||||||
setResetFileKey(fileKeyGen());
|
setResetFileKey(fileKeyGen());
|
||||||
|
setResetContentKey(fileKeyGen());
|
||||||
};
|
};
|
||||||
|
|
||||||
const sendMessage = () => {
|
const sendMessage = () => {
|
||||||
|
@ -171,6 +173,7 @@ const Chat: React.FC<ChatInterface> = ({ chat, inputRef, className }) => {
|
||||||
errorMessage={errorMessage}
|
errorMessage={errorMessage}
|
||||||
onSelectFile={handleFiles}
|
onSelectFile={handleFiles}
|
||||||
resetFileKey={resetFileKey}
|
resetFileKey={resetFileKey}
|
||||||
|
resetContentKey={resetContentKey}
|
||||||
onPaste={handlePaste}
|
onPaste={handlePaste}
|
||||||
attachments={attachment ? [attachment] : []}
|
attachments={attachment ? [attachment] : []}
|
||||||
onDeleteAttachment={handleRemoveFile}
|
onDeleteAttachment={handleRemoveFile}
|
||||||
|
|
Loading…
Reference in a new issue