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 1 commit
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
Prev Previous commit
Next Next commit
fix(ComponentDemo): update knob container code
  • Loading branch information
tw15egan committed Nov 17, 2022
commit 12cc183b1c169a4a6207bebc6b9e04e2aa695baf
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