Skip to content

Commit

Permalink
fix(radiobuttongroup): custom class should merge with base class (car…
Browse files Browse the repository at this point in the history
  • Loading branch information
devniel authored and asudoh committed Feb 4, 2019
1 parent 65ea387 commit a29fb4f
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 5 deletions.
20 changes: 20 additions & 0 deletions src/components/RadioButtonGroup/RadioButtonGroup-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,4 +142,24 @@ describe('RadioButtonGroup', () => {
expect(wrapper.state().selected).toEqual('male');
});
});

describe('Custom class name should stay with original class name', () => {
const wrapper = shallow(
<RadioButtonGroup
className="my-radio-group"
valueSelected="male"
defaultSelected="female"
name="gender">
<RadioButton labelText="Male" value="male" />
<RadioButton labelText="Female" value="female" />
</RadioButtonGroup>
);

it('should found the provided class along with the base class', () => {
expect(wrapper.exists('.my-radio-group')).toBe(true);
expect(wrapper.exists('.bx--radio-button-group.my-radio-group')).toBe(
true
);
});
});
});
13 changes: 8 additions & 5 deletions src/components/RadioButtonGroup/RadioButtonGroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import PropTypes from 'prop-types';
import React from 'react';
import classNames from 'classnames';
import RadioButton from '../RadioButton';
import warning from 'warning';
import { settings } from 'carbon-components';
Expand Down Expand Up @@ -103,14 +104,16 @@ export default class RadioButtonGroup extends React.Component {
};

render() {
const {
disabled,
className = `${prefix}--radio-button-group`,
} = this.props;
const { disabled, className } = this.props;

const wrapperClasses = classNames(
`${prefix}--radio-button-group`,
className
);

return (
<div className={`${prefix}--form-item`}>
<div className={className} disabled={disabled}>
<div className={wrapperClasses} disabled={disabled}>
{this.getRadioButtons()}
</div>
</div>
Expand Down

0 comments on commit a29fb4f

Please sign in to comment.