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 }) {
|
function MessageEdit({ content, onSave, onCancel }) {
|
||||||
const editInputRef = useRef(null);
|
const editInputRef = useRef(null);
|
||||||
|
|
||||||
|
function handleKeyDown(e) {
|
||||||
|
if (e.keyCode === 13 && e.shiftKey === false) {
|
||||||
|
e.preventDefault();
|
||||||
|
onSave(editInputRef.current.value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<form className="message__edit" onSubmit={(e) => { e.preventDefault(); onSave(editInputRef.current.value); }}>
|
<form className="message__edit" onSubmit={(e) => { e.preventDefault(); onSave(editInputRef.current.value); }}>
|
||||||
<Input
|
<Input
|
||||||
forwardRef={editInputRef}
|
forwardRef={editInputRef}
|
||||||
|
onKeyDown={handleKeyDown}
|
||||||
value={content}
|
value={content}
|
||||||
placeholder="Edit message"
|
placeholder="Edit message"
|
||||||
required
|
required
|
||||||
|
|
|
@ -7,7 +7,6 @@ import colorMXID from '../../../util/colorMXID';
|
||||||
import Button from '../../atoms/button/Button';
|
import Button from '../../atoms/button/Button';
|
||||||
import ImageUpload from '../../molecules/image-upload/ImageUpload';
|
import ImageUpload from '../../molecules/image-upload/ImageUpload';
|
||||||
import Input from '../../atoms/input/Input';
|
import Input from '../../atoms/input/Input';
|
||||||
import Text from '../../atoms/text/Text';
|
|
||||||
|
|
||||||
import './ProfileEditor.scss';
|
import './ProfileEditor.scss';
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue