From 6555b237d3f317eaab93ed5006d14c4de6be2291 Mon Sep 17 00:00:00 2001
From: Frank Sauerburger <frank@sauerburger.com>
Date: Mon, 31 May 2021 21:09:47 +0200
Subject: [PATCH] Make caption propagate submit to parent

---
 uhepp-js/src/components/Caption.jsx | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/uhepp-js/src/components/Caption.jsx b/uhepp-js/src/components/Caption.jsx
index 73d7d6a..231da95 100644
--- a/uhepp-js/src/components/Caption.jsx
+++ b/uhepp-js/src/components/Caption.jsx
@@ -1,7 +1,7 @@
 
 import React, { useState } from "react";
 
-const Caption = ({editable, comment}) => {
+const Caption = ({editable, comment, handleUpdate}) => {
   const [editMode, setEditMode] = useState(false)
   const [cmt, setCmt] = useState(comment)
    
@@ -12,6 +12,11 @@ const Caption = ({editable, comment}) => {
     }
   }
 
+  const handleSubmit = (e) => {
+      e.preventDefault()
+      handleUpdate(cmt)
+  }
+
   const softLeave = () => {
     if (comment == cmt) {
       setEditMode(false)
@@ -24,8 +29,10 @@ const Caption = ({editable, comment}) => {
     }
   }
 
+  console.log(style)
+
   if (editMode) {
-    return (<form method="post" className="my-2 d-flex">
+    return (<form method="post" className="my-2 d-flex" onSubmit={e => handleSubmite(e)}>
       <textarea name="comment" cols="40" autoFocus className="textarea form-control"
         onBlur={() => softLeave()}
         id="id_comment" rows="2" value={cmt} onChange={e => updateComment(e)} />
-- 
GitLab