Focus and clear content after sending a message

pull/28217/head
Florian Duros 2022-10-07 10:52:19 +02:00
parent 1d820cf837
commit a50329fb97
No known key found for this signature in database
GPG Key ID: 9700AA5870258A0B
1 changed files with 7 additions and 5 deletions

View File

@ -40,18 +40,20 @@ export function WysiwygComposer(
const mxClient = useMatrixClientContext();
const [content, setContent] = useState<string>();
const { ref, isWysiwygReady } = useWysiwyg({ onChange: (_content) => {
const { ref, isWysiwygReady, wysiwyg } = useWysiwyg({ onChange: (_content) => {
setContent(_content);
onChange(_content);
} });
const memoizedSendMessage = useCallback(() => sendMessage(content, mxClient, { roomContext, ...props }),
[content, mxClient, roomContext, props],
);
const memoizedSendMessage = useCallback(() => {
sendMessage(content, mxClient, { roomContext, ...props });
wysiwyg.clear();
ref.current?.focus();
}, [content, mxClient, roomContext, wysiwyg, props, ref]);
return (
<>
<div className="mx_SendMessageComposer" style={{ minHeight: '30px' }} ref={ref} contentEditable={!disabled && isWysiwygReady} />
<div className="mx_SendMessageComposer" style={{ minHeight: '30px', marginBottom: '5px' }} ref={ref} contentEditable={!disabled && isWysiwygReady} />
{ children?.(memoizedSendMessage) }
</>
);