Fix edit message input not expending properly
authorajbura <ajbura@gmail.com>
Tue, 8 Feb 2022 11:57:57 +0000 (17:27 +0530)
committerajbura <ajbura@gmail.com>
Tue, 8 Feb 2022 11:57:57 +0000 (17:27 +0530)
Signed-off-by: ajbura <ajbura@gmail.com>
src/app/molecules/message/Message.jsx

index 16850f291be8b8535694e1f534e6a6847181b076..d3205d6925731d5ecf2305e1e42e2cc52eafb69d 100644 (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>