diff --git a/uhepp-js/src/components/Caption.jsx b/uhepp-js/src/components/Caption.jsx index 73d7d6a1aa70c9f8688d0487069376b21eee36c9..231da952c95808c0ddb430dd66462c6bd2b1d529 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)} />