diff --git a/CHANGELOG.md b/CHANGELOG.md index 51087f17b3d..edb432f5db2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ - Added a webpack directive for naming icon chunks ([#1944](https://github.com/elastic/eui/pull/1944)) - Added ability to update `EuiInMemoryTable` `sorting` prop and remove columns after sorting is applied ([#1972](https://github.com/elastic/eui/pull/1972)) - Added `onToggle` callback to `EuiAccordion` ([#1974](https://github.com/elastic/eui/pull/1974)) +- Removed `options` `defaultProps` value from `EuiSuperSelect` ([#1975](https://github.com/elastic/eui/pull/1975)) **Bug fixes** diff --git a/src/components/form/super_select/super_select.js b/src/components/form/super_select/super_select.js index eec91607b83..a40f1f6b3ba 100644 --- a/src/components/form/super_select/super_select.js +++ b/src/components/form/super_select/super_select.js @@ -318,5 +318,4 @@ EuiSuperSelect.defaultProps = { fullWidth: false, compressed: false, isInvalid: false, - options: [], }; diff --git a/src/components/form/super_select/super_select.test.js b/src/components/form/super_select/super_select.test.js index 7987ec05d3d..fc44f136699 100644 --- a/src/components/form/super_select/super_select.test.js +++ b/src/components/form/super_select/super_select.test.js @@ -10,10 +10,19 @@ jest.mock('../../portal', () => ({ EuiPortal: ({ children }) => children, })); +const options = [ + { value: '1', inputDisplay: 'Option #1' }, + { value: '2', inputDisplay: 'Option #2' }, +]; + describe('EuiSuperSelect', () => { test('is rendered', () => { const component = render( - {}} /> + {}} + /> ); expect(component).toMatchSnapshot(); @@ -22,7 +31,12 @@ describe('EuiSuperSelect', () => { describe('props', () => { test('fullWidth is rendered', () => { const component = render( - {}} fullWidth /> + {}} + fullWidth + /> ); expect(component).toMatchSnapshot(); @@ -45,10 +59,7 @@ describe('EuiSuperSelect', () => { test('options are rendered when select is open', () => { const component = mount( {}} data-test-subj="superSelect" /> @@ -62,10 +73,7 @@ describe('EuiSuperSelect', () => { test('valueSelected is rendered', () => { const component = render( {}} /> diff --git a/src/components/form/super_select/super_select_control.js b/src/components/form/super_select/super_select_control.js index 2b3ca019e28..7e44135776f 100644 --- a/src/components/form/super_select/super_select_control.js +++ b/src/components/form/super_select/super_select_control.js @@ -41,7 +41,9 @@ export const EuiSuperSelectControl = ({ let selectedValue = ''; if (value) { const selectedOption = options.find(option => option.value === value); - selectedValue = selectedOption.inputDisplay; + selectedValue = selectedOption + ? selectedOption.inputDisplay + : selectedValue; } const icon = {