Skip to content
Snippets Groups Projects
Verified Commit 6555b237 authored by Frank Sauerburger's avatar Frank Sauerburger
Browse files

Make caption propagate submit to parent

parent c7619d21
Branches 73-add-non-uhepp-comments-description-for-each-plot
No related tags found
1 merge request!31Resolve "Add non-uhepp comments/description for each plot"
Pipeline #7978 waiting for manual action
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)} />
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment