({
+ isOpen: !prevState.isOpen
+ }));
}
render() {
@@ -96,7 +94,7 @@ export class EuiAccordion extends Component {
onClick={this.onToggle}
className={buttonClasses}
>
-
+
{icon}
diff --git a/src/components/form/radio/__snapshots__/radio.test.js.snap b/src/components/form/radio/__snapshots__/radio.test.js.snap
index 005cb1b2df7..c8185389f55 100644
--- a/src/components/form/radio/__snapshots__/radio.test.js.snap
+++ b/src/components/form/radio/__snapshots__/radio.test.js.snap
@@ -71,3 +71,19 @@ exports[`EuiRadio props label is rendered 1`] = `
`;
+
+exports[`EuiRadio props value is rendered 1`] = `
+
+`;
diff --git a/src/components/form/radio/__snapshots__/radio_group.test.js.snap b/src/components/form/radio/__snapshots__/radio_group.test.js.snap
index 59d16f99958..eafc29ab7fe 100644
--- a/src/components/form/radio/__snapshots__/radio_group.test.js.snap
+++ b/src/components/form/radio/__snapshots__/radio_group.test.js.snap
@@ -133,3 +133,48 @@ exports[`EuiRadioGroup props options are rendered 1`] = `
`;
+
+exports[`EuiRadioGroup props value is propagated to radios 1`] = `
+
+`;
diff --git a/src/components/form/radio/radio.js b/src/components/form/radio/radio.js
index a4798fb5923..a6ec70fa3fd 100644
--- a/src/components/form/radio/radio.js
+++ b/src/components/form/radio/radio.js
@@ -8,6 +8,7 @@ export const EuiRadio = ({
name,
checked,
label,
+ value,
onChange,
disabled,
...rest
@@ -43,6 +44,7 @@ export const EuiRadio = ({
type="radio"
id={id}
name={name}
+ value={value}
checked={checked}
onChange={onChange}
disabled={disabled}
@@ -60,6 +62,7 @@ EuiRadio.propTypes = {
id: PropTypes.string.isRequired,
checked: PropTypes.bool.isRequired,
label: PropTypes.node,
+ value: PropTypes.string,
onChange: PropTypes.func.isRequired,
disabled: PropTypes.bool,
};
diff --git a/src/components/form/radio/radio.test.js b/src/components/form/radio/radio.test.js
index 153f04ac4d8..b0a36b9370c 100644
--- a/src/components/form/radio/radio.test.js
+++ b/src/components/form/radio/radio.test.js
@@ -33,6 +33,15 @@ describe('EuiRadio', () => {
.toMatchSnapshot();
});
+ test('value is rendered', () => {
+ const component = render(
+
{}} value={'bobbins'}/>
+ );
+
+ expect(component)
+ .toMatchSnapshot();
+ });
+
test('disabled is rendered', () => {
const component = render(
{}} disabled/>
diff --git a/src/components/form/radio/radio_group.behavior.test.js b/src/components/form/radio/radio_group.behavior.test.js
deleted file mode 100644
index 74664870feb..00000000000
--- a/src/components/form/radio/radio_group.behavior.test.js
+++ /dev/null
@@ -1,26 +0,0 @@
-import React from 'react';
-import { mount } from 'enzyme';
-import sinon from 'sinon';
-
-import { EuiRadioGroup } from './radio_group';
-
-// This exists because we need to run the following tests
-// without mocking the Radio component, such as testing
-// an interaction that is handled by the Radio component.
-describe('EuiRadioGroup behavior', () => {
- test('id is bound to onChange', () => {
- const onChangeHandler = sinon.stub();
- const component = mount(
-
- );
-
- component.find('input[type="radio"]').simulate('change');
- sinon.assert.calledWith(onChangeHandler, '1');
- });
-});
diff --git a/src/components/form/radio/radio_group.js b/src/components/form/radio/radio_group.js
index 044bd204142..f4be843b6b0 100644
--- a/src/components/form/radio/radio_group.js
+++ b/src/components/form/radio/radio_group.js
@@ -22,8 +22,9 @@ export const EuiRadioGroup = ({
name={name}
checked={option.id === idSelected}
label={option.label}
+ value={option.value}
disabled={disabled}
- onChange={onChange.bind(null, option.id)}
+ onChange={onChange.bind(null, option.id, option.value)}
/>
);
})}
@@ -35,6 +36,7 @@ EuiRadioGroup.propTypes = {
PropTypes.shape({
id: PropTypes.string.isRequired,
label: PropTypes.node,
+ value: PropTypes.string,
}),
).isRequired,
idSelected: PropTypes.string,
diff --git a/src/components/form/radio/radio_group.test.js b/src/components/form/radio/radio_group.test.js
index de17a99e389..8c7e67dc755 100644
--- a/src/components/form/radio/radio_group.test.js
+++ b/src/components/form/radio/radio_group.test.js
@@ -1,5 +1,5 @@
import React from 'react';
-import { render } from 'enzyme';
+import { render, mount } from 'enzyme';
import { requiredProps } from '../../../test';
import { EuiRadioGroup } from './radio_group';
@@ -63,5 +63,65 @@ describe('EuiRadioGroup', () => {
expect(component)
.toMatchSnapshot();
});
+
+ test('value is propagated to radios', () => {
+ const component = render(
+ {}}
+ />
+ );
+
+ expect(component)
+ .toMatchSnapshot();
+ });
+ });
+
+ describe('callbacks', () => {
+ test('id is used in callbacks when no value is available', () => {
+ const callback = jest.fn();
+
+ const component = mount(
+
+ );
+
+ component.find('input[id="2"]').simulate('change');
+
+ expect(callback).toHaveBeenCalledTimes(1);
+ const event = expect.any(Object);
+ expect(callback).toHaveBeenCalledWith('2', undefined, event);
+ });
+
+ test('value is used in callbacks when available', () => {
+ const callback = jest.fn();
+
+ const component = mount(
+
+ );
+
+ component.find('input[id="2"]').simulate('change');
+
+ expect(callback).toHaveBeenCalledTimes(1);
+ const event = expect.any(Object);
+ expect(callback).toHaveBeenCalledWith('2', 'Value #2', event);
+ });
});
});