Skip to content

Commit

Permalink
fix(Radio): Updated Radio aria-label prop so that it is optional (pat…
Browse files Browse the repository at this point in the history
  • Loading branch information
tlabaj authored and jschuler committed Nov 27, 2018
1 parent 9e41c6c commit a3e74fa
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export interface RadioProps extends Omit<HTMLProps<HTMLInputElement>, 'type' | '
isChecked?: boolean;
onChange?(checked: boolean, event: FormEvent<HTMLInputElement>): void;
id: string;
'aria-label': string;
'aria-label'?: string;
label?: ReactNode;
name: string;
}
Expand Down
10 changes: 8 additions & 2 deletions packages/patternfly-4/react-core/src/components/Radio/Radio.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@ const propTypes = {
/** Id of the Radio. */
id: PropTypes.string.isRequired,
/** Aria-label of the Radio. */
'aria-label': PropTypes.any.isRequired,
'aria-label': props => {
if (!props['aria-label']) {
return new Error('Radio requires an aria-label to be specified');
}
return null;
},
/** Name for group of Radios */
name: PropTypes.string.isRequired
};
Expand All @@ -30,7 +35,8 @@ const defaultProps = {
isDisabled: false,
isChecked: null,
onChange: () => undefined,
label: undefined
label: undefined,
'aria-label': null
};

class Radio extends React.Component {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class ControlledRadio extends React.Component {
<Radio
value="4"
isChecked={this.state.value === '4'}
name="pf-version"
name="pf-version2"
onChange={this.handleChange}
aria-label="Controlled radio 2"
label="Controlled radio 2"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class CustomLabelRadio extends React.Component {
<Radio
label={<Badge isRead>Different badge!</Badge>}
id="radio-7"
name="radios-custom"
name="radios-custom2"
aria-label="custom-label-2"
/>
</React.Fragment>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class DisabledRadio extends React.Component {
aria-label="disabled checked radio example"
defaultChecked
isDisabled
name="group-2"
name="group-1"
id="radio-disabled"
/>{' '}
<Radio
Expand Down

0 comments on commit a3e74fa

Please sign in to comment.