diff --git a/src/components/Exercises/WriteBlanks.tsx b/src/components/Exercises/WriteBlanks.tsx index bbbc6bd7..3351687f 100644 --- a/src/components/Exercises/WriteBlanks.tsx +++ b/src/components/Exercises/WriteBlanks.tsx @@ -12,6 +12,7 @@ import Button from "../Low/Button"; function Blank({ id, maxWords, + userSolution, showSolutions = false, setUserSolution, }: { @@ -20,9 +21,9 @@ function Blank({ userSolution?: string; maxWords: number; showSolutions?: boolean; - setUserSolution?: (solution: string) => void; + setUserSolution: (solution: string) => void; }) { - const [userInput, setUserInput] = useState(""); + const [userInput, setUserInput] = useState(userSolution || ""); useEffect(() => { const words = userInput.split(" ").filter((x) => x !== ""); @@ -37,6 +38,7 @@ function Blank({ className={clsx("input border rounded-xl px-2 py-1 bg-white text-blue-400 border-blue-400 my-2")} placeholder={id} onChange={(e) => setUserInput(e.target.value)} + onBlur={() => setUserSolution(userInput)} value={userInput} contentEditable={showSolutions} />