Skip to content

Commit

Permalink
fix(components): disable pointer event if showing result
Browse files Browse the repository at this point in the history
  • Loading branch information
SecondThundeR committed Aug 10, 2023
1 parent 3477854 commit 48c9b27
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/components/QuestionButtons/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export const QuestionButtons = memo(function QuestionButtons({
);

const showSelected = correctButtonID !== false;
const isPointerDisabled = showSelected && correctButtonID !== null;

const getButtonStyle = (buttonID: string) => {
if (!correctButtonID) return "primary";
Expand Down Expand Up @@ -56,16 +57,18 @@ export const QuestionButtons = memo(function QuestionButtons({
{shuffledButtons.map((anime) => {
const { id, name } = anime;
const isButtonSelected = id === selectedButtonID;
const isSuffixAdded = showSelected && isButtonSelected;
const buttonStyle = getButtonStyle(id);

return (
<Button
key={id}
style={buttonStyle}
onClick={() => onClick(anime)}
className={isPointerDisabled ? "pointer-events-none" : undefined}
disabled={isDisabled}
>
{showSelected && isButtonSelected && "Выбрано:"} {name}
{isSuffixAdded && "Выбрано:"} {name}
</Button>
);
})}
Expand Down

0 comments on commit 48c9b27

Please sign in to comment.