Focus and clear content after sending a message
This commit is contained in:
parent
1d820cf837
commit
a50329fb97
1 changed files with 7 additions and 5 deletions
|
@ -40,18 +40,20 @@ export function WysiwygComposer(
|
||||||
const mxClient = useMatrixClientContext();
|
const mxClient = useMatrixClientContext();
|
||||||
|
|
||||||
const [content, setContent] = useState<string>();
|
const [content, setContent] = useState<string>();
|
||||||
const { ref, isWysiwygReady } = useWysiwyg({ onChange: (_content) => {
|
const { ref, isWysiwygReady, wysiwyg } = useWysiwyg({ onChange: (_content) => {
|
||||||
setContent(_content);
|
setContent(_content);
|
||||||
onChange(_content);
|
onChange(_content);
|
||||||
} });
|
} });
|
||||||
|
|
||||||
const memoizedSendMessage = useCallback(() => sendMessage(content, mxClient, { roomContext, ...props }),
|
const memoizedSendMessage = useCallback(() => {
|
||||||
[content, mxClient, roomContext, props],
|
sendMessage(content, mxClient, { roomContext, ...props });
|
||||||
);
|
wysiwyg.clear();
|
||||||
|
ref.current?.focus();
|
||||||
|
}, [content, mxClient, roomContext, wysiwyg, props, ref]);
|
||||||
|
|
||||||
return (
|
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) }
|
{ children?.(memoizedSendMessage) }
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue