Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(RadioButton): fix a11y issues with RadioButtonGroup #3276

Merged
merged 4 commits into from
Nov 28, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/components/ComponentDemo/ComponentDemo.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -233,14 +233,16 @@

// custom classnames are being applied to both fieldset and label
// https://github.com/carbon-design-system/carbon/issues/4572
fieldset.form-group {
fieldset.form-group,
fieldset[class*='--radio-button-group'] {
padding: 1rem;
padding-top: 0;
margin-bottom: 0;
border-bottom: 1px solid $ui-03;
}

fieldset.form-group:last-of-type {
fieldset.form-group:last-of-type,
fieldset[class*='--radio-button-group']:last-of-type {
border-bottom: 0;
}

Expand Down
40 changes: 18 additions & 22 deletions src/components/ComponentDemo/KnobContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,7 @@ const Component = ({
<div
role="group"
aria-labelledby={componentGroupId}
className={componentKnobWrapper}
>
className={componentKnobWrapper}>
{booleanKnobs.length > 0 && (
<FormGroup className={formGroup} legendText="Modifiers">
{booleanKnobs.map(([name, info]) => (
Expand Down Expand Up @@ -228,22 +227,21 @@ const Knob = ({
}

return (
<FormGroup className={formGroup} legendText={name}>
<RadioButtonGroup
onChange={(val) => updateKnob(val)}
defaultSelected={defaultSelected}
name={name}
orientation="vertical"
>
{values.map(({ value }) => (
<RadioButton
key={`${inputId}-${value}`}
value={value}
labelText={value.replace(/'/g, '')}
/>
))}
</RadioButtonGroup>
</FormGroup>
<RadioButtonGroup
className={formGroup}
legendText={name}
onChange={(val) => updateKnob(val)}
defaultSelected={defaultSelected}
name={name}
orientation="vertical">
{values.map(({ value }) => (
<RadioButton
key={`${inputId}-${value}`}
value={value}
labelText={value.replace(/'/g, '')}
/>
))}
</RadioButtonGroup>
);
}
return '';
Expand Down Expand Up @@ -291,15 +289,13 @@ const KnobContainer = ({ knobs, code, setCode, initialCode, variantId }) => {
<Form
className={cx(knobContainer, {
[knobContainerCollapsed]: isMobile && isKnobContainerCollapsed,
})}
>
})}>
{isMobile && (
<div className={iconButtonRow}>
<button
className={iconButton}
type="button"
onClick={() => setIsKnobContainerCollapsed(true)}
>
onClick={() => setIsKnobContainerCollapsed(true)}>
<Close size={20} />
</button>
</div>
Expand Down
6 changes: 1 addition & 5 deletions src/pages/components/radio-button/code.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,9 @@ usage documentation, see the Storybooks for each framework below.
}}
>
{`
<FormGroup
legendText="Radio button heading"
>
<RadioButtonGroup
defaultSelected="default-selected"
legend="Group Legend"
legendText="Radio button heading"
name="radio-button-group"
valueSelected="default-selected"
>
Expand All @@ -109,7 +106,6 @@ usage documentation, see the Storybooks for each framework below.
value="disabled"
/>
</RadioButtonGroup>
</FormGroup>
`}
</ComponentVariant>
</ComponentDemo>
6 changes: 1 addition & 5 deletions src/pages/components/radio-button/usage.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,9 @@ checkboxes allow the user to select multiple items.
}}
>
{`
<FormGroup
legendText="Radio button heading"
>
<RadioButtonGroup
defaultSelected="default-selected"
legend="Group Legend"
legendText="Radio button heading"
name="radio-button-group"
valueSelected="default-selected"
>
Expand All @@ -122,7 +119,6 @@ checkboxes allow the user to select multiple items.
value="disabled"
/>
</RadioButtonGroup>
</FormGroup>
`}
</ComponentVariant>
</ComponentDemo>
Expand Down