Combining RadioGroup with Field/Fieldset #3720
-
ContextFirst off, thank you for building Ark UI: it's become an essential part of our Vue design system. 💜 We are building a Vue 3 design system using Ark UI. I need RadioGroup to work with Fieldset components to provide:
I notice that Approach 1: Fieldset wrapping RadioGroup<Fieldset.Root :invalid="validationState === 'error'">
<Fieldset.Legend>Select your pet</Fieldset.Legend>
<Fieldset.HelperText>Choose your favourite</Fieldset.HelperText>
<RadioGroup.Root>
<RadioGroup.Item value="dogs">Dogs</RadioGroup.Item>
<RadioGroup.Item value="cats">Cats</RadioGroup.Item>
</RadioGroup.Root>
<Fieldset.ErrorText>Please select an option</Fieldset.ErrorText>
</Fieldset.Root>Issues1. Broken The rendered HTML shows: <fieldset aria-labelledby="fieldset::v-0::legend">
<legend id="fieldset::v-0::legend">Select your pet</legend>
<div role="radiogroup" aria-labelledby="radio-group:v-1:label">
<!-- ❌ Points to non-existent element! -->
</div>
</fieldset>
2. No I can't propagate invalid state to the Approach 2: Using RadioGroup.Label instead of Fieldset<Field.Root :invalid="validationState === 'error'">
<RadioGroup.Root>
<RadioGroup.Label>Select your pet</RadioGroup.Label>
<Field.HelperText>Choose your favourite</Field.HelperText>
<RadioGroup.Item value="dogs">Dogs</RadioGroup.Item>
<RadioGroup.Item value="cats">Cats</RadioGroup.Item>
<Field.ErrorText>Please select an option</Field.ErrorText>
</RadioGroup.Root>
</Field.Root>Issues1. When 2. The Questions
Potential SolutionFirst-class Fieldset integration (like Checkbox.Group)
Current behaviour: When Suggested: When
This would give RadioGroup the same Fieldset integration that Checkbox.Group already has. Environment
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
|
Good points! I'm adding support for this in Zag.js shortly. It'll be added to Ark pretty soon |
Beta Was this translation helpful? Give feedback.
I just pushed a fix for this. We'll release an update shortly.