Single select question radios (#965)

* fix(ui): make radios not jump around upon state change

* fix(ui): use radios for single-select questions instead of checkboxes
This commit is contained in:
Les De Ridder
2026-04-21 20:28:50 +03:00
committed by GitHub
parent 2f5912c287
commit 36b177dc81
2 changed files with 22 additions and 14 deletions
@@ -1,6 +1,7 @@
import React from 'react'; import React from 'react';
import { RiArrowRightSLine, RiCheckLine, RiCloseLine, RiEditLine, RiListCheck3, RiQuestionLine } from '@remixicon/react'; import { RiArrowRightSLine, RiCheckLine, RiCloseLine, RiEditLine, RiListCheck3, RiQuestionLine } from '@remixicon/react';
import { Checkbox } from '@/components/ui/checkbox'; import { Checkbox } from '@/components/ui/checkbox';
import { Radio } from '@/components/ui/radio';
import { cn } from '@/lib/utils'; import { cn } from '@/lib/utils';
import type { QuestionRequest } from '@/types/question'; import type { QuestionRequest } from '@/types/question';
@@ -295,11 +296,19 @@ export const QuestionCard: React.FC<QuestionCardProps> = ({ question }) => {
> >
<div className="flex items-start gap-2"> <div className="flex items-start gap-2">
<div className="mt-0.5 shrink-0"> <div className="mt-0.5 shrink-0">
{isMultiple ? (
<Checkbox <Checkbox
checked={selected} checked={selected}
onChange={() => handleToggleOption(option.label)} onChange={() => handleToggleOption(option.label)}
disabled={isResponding} disabled={isResponding}
/> />
) : (
<Radio
checked={selected}
onChange={() => handleToggleOption(option.label)}
disabled={isResponding}
/>
)}
</div> </div>
<div className="min-w-0 flex-1"> <div className="min-w-0 flex-1">
+1 -2
View File
@@ -62,15 +62,14 @@ export const Radio = React.memo<RadioProps>(function Radio({
className, className,
)} )}
> >
{checked ? (
<span <span
aria-hidden aria-hidden
className={cn( className={cn(
'block h-[5px] w-[5px] rounded-full bg-white', 'block h-[5px] w-[5px] rounded-full bg-white',
!checked && 'opacity-0',
iconClassName, iconClassName,
)} )}
/> />
) : null}
</button> </button>
); );
}); });