Skip to content

Commit cf8d045

Browse files
committed
fix: onBlur
1 parent 5a70e2e commit cf8d045

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

app/components/form/field-radio-group/index.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export const FieldRadioGroup = <
6060
disabled={disabled}
6161
defaultValue={defaultValue}
6262
shouldUnregister={shouldUnregister}
63-
render={({ field: { onChange, ...field }, fieldState }) => (
63+
render={({ field: { onChange, onBlur, ...field }, fieldState }) => (
6464
<div
6565
{...containerProps}
6666
className={cn(
@@ -82,9 +82,10 @@ export const FieldRadioGroup = <
8282
>
8383
{options.map((option) => (
8484
<Radio
85-
key={option.value}
85+
key={`${ctx.id}-${option.value}`}
8686
value={option.value}
8787
disabled={option.disabled}
88+
onBlur={onBlur}
8889
>
8990
{option.label}
9091
</Radio>

app/components/ui/radio-group.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ function Radio({
2828
children,
2929
...props
3030
}: RadioProps) {
31+
const _radioId = React.useId();
32+
3133
return (
3234
<div
3335
{...containerProps}
@@ -38,7 +40,7 @@ function Radio({
3840
'peer aspect-square h-4 w-4 cursor-pointer rounded-full border border-primary text-primary ring-offset-background focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50',
3941
className
4042
)}
41-
id={value}
43+
id={_radioId}
4244
value={value}
4345
{...props}
4446
>
@@ -47,7 +49,7 @@ function Radio({
4749
</RadioGroupPrimitive.Indicator>
4850
</RadioGroupPrimitive.Item>
4951
<label
50-
htmlFor={value}
52+
htmlFor={_radioId}
5153
{...labelProps}
5254
className={cn(
5355
'cursor-pointer text-xs peer-disabled:cursor-not-allowed',

0 commit comments

Comments
 (0)