Fix edit message input not expending properly

Signed-off-by: ajbura <ajbura@gmail.com>
This commit is contained in:
ajbura 2022-02-08 17:27:57 +05:30
parent cdd909f2dd
commit a17d5d01a7

View file

@ -248,10 +248,8 @@ function MessageEdit({ body, onSave, onCancel }) {
const editInputRef = useRef(null);
useEffect(() => {
editInputRef.current.focus();
// Setting the value here instead of using the value prop below
// makes the cursor end up at the end of the line instead of the begining
// makes the cursor end up at the end of the line instead of the beginning
editInputRef.current.value = '';
editInputRef.current.value = body;
}, []);
@ -267,9 +265,11 @@ function MessageEdit({ body, onSave, onCancel }) {
<Input
forwardRef={editInputRef}
onKeyDown={handleKeyDown}
value={body}
placeholder="Edit message"
required
resizable
autoFocus
/>
<div className="message__edit-btns">
<Button type="submit" variant="primary">Save</Button>