Skip to content

Commit

Permalink
Allow setting autoFocus on radio group option (elastic#1117)
Browse files Browse the repository at this point in the history
* Allow setting autoFocus on radio group option

* pass optionRest to EuiRadio

* remove autoFocus from RadioGroup since it is now passed via optionRest

* pass id, value, and label via optionRest
  • Loading branch information
nreese authored Aug 16, 2018
1 parent a35590f commit 06d6ab5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
3 changes: 3 additions & 0 deletions src/components/form/radio/radio.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export const EuiRadio = ({
onChange,
disabled,
compressed,
autoFocus,
...rest
}) => {
const classes = classNames(
Expand Down Expand Up @@ -50,6 +51,7 @@ export const EuiRadio = ({
checked={checked}
onChange={onChange}
disabled={disabled}
autoFocus={autoFocus}
/>

<div className="euiRadio__circle" />
Expand All @@ -71,6 +73,7 @@ EuiRadio.propTypes = {
* when `true` creates a shorter height radio row
*/
compressed: PropTypes.bool,
autoFocus: PropTypes.bool,
};

EuiRadio.defaultProps = {
Expand Down
10 changes: 6 additions & 4 deletions src/components/form/radio/radio_group.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,20 @@ export const EuiRadioGroup = ({
}) => (
<div className={className} {...rest}>
{options.map((option, index) => {
const {
disabled: isOptionDisabled,
...optionRest
} = option;
return (
<EuiRadio
className="euiRadioGroup__item"
key={index}
id={option.id}
name={name}
checked={option.id === idSelected}
label={option.label}
value={option.value}
disabled={disabled || option.disabled}
disabled={disabled || isOptionDisabled}
onChange={onChange.bind(null, option.id, option.value)}
compressed={compressed}
{...optionRest}
/>
);
})}
Expand Down

0 comments on commit 06d6ab5

Please sign in to comment.