Skip to content
Snippets Groups Projects

Resolve "Add non-uhepp comments/description for each plot"

1 file
+ 9
2
Compare changes
  • Side-by-side
  • Inline
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)} />
Loading