@@ -7,10 +7,8 @@ import CheckboxOrRadioGroupValidation from './CheckboxOrRadioGroupValidation'
77import CheckboxOrRadioGroupContext from './CheckboxOrRadioGroupContext'
88import VisuallyHidden from '../../../_VisuallyHidden'
99import { useSlots } from '../../../hooks/useSlots'
10- import type { SxProp } from '../../../sx'
1110import classes from './CheckboxOrRadioGroup.module.css'
1211import { clsx } from 'clsx'
13- import { BoxWithFallback } from '../BoxWithFallback'
1412
1513export type CheckboxOrRadioGroupProps = {
1614 /** Class name for custom styling */
@@ -32,7 +30,7 @@ export type CheckboxOrRadioGroupProps = {
3230 * If true, the user must make a selection before the owning form can be submitted
3331 */
3432 required ?: boolean
35- } & SxProp
33+ }
3634
3735const CheckboxOrRadioGroup : React . FC < React . PropsWithChildren < CheckboxOrRadioGroupProps > > = ( {
3836 'aria-labelledby' : ariaLabelledby ,
@@ -41,7 +39,6 @@ const CheckboxOrRadioGroup: React.FC<React.PropsWithChildren<CheckboxOrRadioGrou
4139 id : idProp ,
4240 required = false ,
4341 className,
44- sx,
4542} ) => {
4643 const [ slots , rest ] = useSlots ( children , {
4744 caption : CheckboxOrRadioGroupCaption ,
@@ -70,6 +67,8 @@ const CheckboxOrRadioGroup: React.FC<React.PropsWithChildren<CheckboxOrRadioGrou
7067
7168 const isLegendVisible = React . isValidElement ( labelChild ) && ! labelChild . props . visuallyHidden
7269
70+ const Component = labelChild ? 'fieldset' : 'div'
71+
7372 return (
7473 < CheckboxOrRadioGroupContext . Provider
7574 value = { {
@@ -80,16 +79,14 @@ const CheckboxOrRadioGroup: React.FC<React.PropsWithChildren<CheckboxOrRadioGrou
8079 } }
8180 >
8281 < div >
83- < BoxWithFallback
82+ < Component
8483 className = { clsx ( className , classes . GroupFieldset ) }
8584 data-validation = { validationChild ? '' : undefined }
8685 { ...( labelChild
8786 ? {
88- as : 'fieldset' ,
8987 disabled,
9088 }
9189 : { } ) }
92- sx = { sx }
9390 >
9491 { labelChild ? (
9592 /*
@@ -126,7 +123,7 @@ const CheckboxOrRadioGroup: React.FC<React.PropsWithChildren<CheckboxOrRadioGrou
126123 >
127124 { React . Children . toArray ( rest ) . filter ( child => React . isValidElement ( child ) ) }
128125 </ div >
129- </ BoxWithFallback >
126+ </ Component >
130127 { validationChild && (
131128 < ValidationAnimationContainer
132129 // If we have CheckboxOrRadioGroup.Label as a child, we render a screenreader-accessible validation message in the <legend>
0 commit comments