Skip to content

Commit

Permalink
Merge pull request #30 from cbvora/controlled_inuput
Browse files Browse the repository at this point in the history
making input as controlled compoenent
  • Loading branch information
cbvora committed Jun 16, 2024
2 parents b5b4598 + 6be0cd7 commit a33cf2e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 3 additions & 3 deletions components/QuizForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ const QuizForm: FC<Props> = ({
if (savedAnswer !== null && typeof savedAnswer === "string") {
return savedAnswer === optionText;
} else {
return;
return false;
}
};

Expand Down Expand Up @@ -168,7 +168,7 @@ const QuizForm: FC<Props> = ({
if (savedAnswer?.length) {
return savedAnswer.includes(optionText);
} else {
return;
return false;
}
};

Expand Down Expand Up @@ -316,7 +316,7 @@ const QuizForm: FC<Props> = ({
showCorrectAnswer[currentQuestionIndex] || false
}
disabled={showCorrectAnswer[currentQuestionIndex] || false}
defaultChecked={
checked={
isOptionChecked(option.text) ||
isOptionCheckedWithoutReveal(option.text)
}
Expand Down
2 changes: 2 additions & 0 deletions components/SelectionInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const SelectionInput = forwardRef<HTMLInputElement, Props>(
showCorrectAnswer,
disabled = false,
defaultChecked,
checked,
handleChange = () => {},
...rest
},
Expand All @@ -38,6 +39,7 @@ const SelectionInput = forwardRef<HTMLInputElement, Props>(
id={id}
className={`peer hidden [&:checked_+_label_svg_path]:block `}
defaultChecked={defaultChecked}
checked={checked}
onClick={handleChange}
{...rest}
/>
Expand Down

0 comments on commit a33cf2e

Please sign in to comment.