Save edited message on enter (#78)
This commit is contained in:
parent
767784a79c
commit
0bbe6a0a12
2 changed files with 9 additions and 1 deletions
|
@ -128,10 +128,19 @@ MessageContent.propTypes = {
|
|||
|
||||
function MessageEdit({ content, onSave, onCancel }) {
|
||||
const editInputRef = useRef(null);
|
||||
|
||||
function handleKeyDown(e) {
|
||||
if (e.keyCode === 13 && e.shiftKey === false) {
|
||||
e.preventDefault();
|
||||
onSave(editInputRef.current.value);
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<form className="message__edit" onSubmit={(e) => { e.preventDefault(); onSave(editInputRef.current.value); }}>
|
||||
<Input
|
||||
forwardRef={editInputRef}
|
||||
onKeyDown={handleKeyDown}
|
||||
value={content}
|
||||
placeholder="Edit message"
|
||||
required
|
||||
|
|
|
@ -7,7 +7,6 @@ import colorMXID from '../../../util/colorMXID';
|
|||
import Button from '../../atoms/button/Button';
|
||||
import ImageUpload from '../../molecules/image-upload/ImageUpload';
|
||||
import Input from '../../atoms/input/Input';
|
||||
import Text from '../../atoms/text/Text';
|
||||
|
||||
import './ProfileEditor.scss';
|
||||
|
||||
|
|
Loading…
Reference in a new issue