Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove options defaultProps value from EuiSuperSelect #1975

Merged
merged 4 commits into from
May 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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**

Expand Down
1 change: 0 additions & 1 deletion src/components/form/super_select/super_select.js
Original file line number Diff line number Diff line change
Expand Up @@ -318,5 +318,4 @@ EuiSuperSelect.defaultProps = {
fullWidth: false,
compressed: false,
isInvalid: false,
options: [],
};
28 changes: 18 additions & 10 deletions src/components/form/super_select/super_select.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
<EuiSuperSelect {...requiredProps} onChange={() => {}} />
<EuiSuperSelect
{...requiredProps}
options={options}
onChange={() => {}}
/>
);

expect(component).toMatchSnapshot();
Expand All @@ -22,7 +31,12 @@ describe('EuiSuperSelect', () => {
describe('props', () => {
test('fullWidth is rendered', () => {
const component = render(
<EuiSuperSelect {...requiredProps} onChange={() => {}} fullWidth />
<EuiSuperSelect
{...requiredProps}
options={options}
onChange={() => {}}
fullWidth
/>
);

expect(component).toMatchSnapshot();
Expand All @@ -45,10 +59,7 @@ describe('EuiSuperSelect', () => {
test('options are rendered when select is open', () => {
const component = mount(
<EuiSuperSelect
options={[
{ value: '1', inputDisplay: 'Option #1' },
{ value: '2', inputDisplay: 'Option #2' },
]}
options={options}
onChange={() => {}}
data-test-subj="superSelect"
/>
Expand All @@ -62,10 +73,7 @@ describe('EuiSuperSelect', () => {
test('valueSelected is rendered', () => {
const component = render(
<EuiSuperSelect
options={[
{ value: '1', inputDisplay: 'Option #1' },
{ value: '2', inputDisplay: 'Option #2' },
]}
options={options}
valueOfSelected="2"
onChange={() => {}}
/>
Expand Down
4 changes: 3 additions & 1 deletion src/components/form/super_select/super_select_control.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down