Solved a bug in WriteBlanks where it wasn't saving the user's answer
This commit is contained in:
@@ -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}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user