sokko-g/website/src/features/toolboxes/modules/MemoTextEditor.jsx
Shinuwa 4f644ca116
Some checks failed
Deploy Sokko G / deploy (push) Failing after 2s
Preserve memo drafts and stabilize goal tree selection
2026-09-11 13:58:00 +02:00

29 lines
947 B
JavaScript

// Rôle : conserve le brouillon d'un mémo et ajuste la hauteur de son champ.
import { useLayoutEffect } from "react";
import { useInlineEdit } from "../../../hooks/useInlineEdit.js";
export function MemoTextEditor({ text, textContent, onCommit }) {
const { draft, setDraft, inputRef, commit } = useInlineEdit({ value: text, onCommit, commitUnchanged: true });
useLayoutEffect(() => {
const element = inputRef.current;
if (!element) return;
element.style.height = "auto";
element.style.height = `${element.scrollHeight + 2}px`;
});
return (
<textarea
className="nds-textarea"
data-size="sm"
data-variant="ghost"
ref={inputRef}
value={draft}
rows={3}
placeholder={textContent.placeholder || "Mémo court..."}
onChange={(event) => setDraft(event.target.value)}
onBlur={() => commit()}
aria-label={textContent.editLabel || "Modifier le mémo"}
/>
);
}