From c3527aff4850eaa6c647eee11d6e4e26034f76b4 Mon Sep 17 00:00:00 2001 From: Nathan Reese Date: Fri, 16 Nov 2018 17:45:51 -0700 Subject: [PATCH 1/4] check for empty string before setting defaultValue --- .../super_select/super_select_complex.js | 2 +- .../super_select_control.test.js.snap | 59 +++++++++++++++++++ .../form/super_select/super_select_control.js | 2 +- .../super_select/super_select_control.test.js | 16 +++++ 4 files changed, 77 insertions(+), 2 deletions(-) diff --git a/src-docs/src/views/super_select/super_select_complex.js b/src-docs/src/views/super_select/super_select_complex.js index 3a410f293f8..df0bb811d81 100644 --- a/src-docs/src/views/super_select/super_select_complex.js +++ b/src-docs/src/views/super_select/super_select_complex.js @@ -56,7 +56,7 @@ export default class extends Component { ]; this.state = { - value: this.options[1].value, + value: '', }; } diff --git a/src/components/form/super_select/__snapshots__/super_select_control.test.js.snap b/src/components/form/super_select/__snapshots__/super_select_control.test.js.snap index fb59b3c13c2..35651636266 100644 --- a/src/components/form/super_select/__snapshots__/super_select_control.test.js.snap +++ b/src/components/form/super_select/__snapshots__/super_select_control.test.js.snap @@ -179,6 +179,65 @@ Array [ ] `; +exports[`EuiSuperSelectControl props empty value option is rendered 1`] = ` +Array [ + , +
+
+ + Select an option: , is selected + +
+
, +] +`; + exports[`EuiSuperSelectControl props fullWidth is rendered 1`] = ` Array [ { expect(component) .toMatchSnapshot(); }); + + test('empty value option is rendered', () => { + const component = render( + {}} + /> + ); + + expect(component) + .toMatchSnapshot(); + }); }); }); From 2925b3d631d5adceac5742113ce5b2f7048753d0 Mon Sep 17 00:00:00 2001 From: Nathan Reese Date: Fri, 16 Nov 2018 17:53:11 -0700 Subject: [PATCH 2/4] change log --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b3c6b4fe414..dc0a86eb20f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ - `EuiBasicTable` now converts the `EuiTableRowCell` `header` into `undefined` if it's been provided as a non-string node, hiding the header and preventing the node from being rendered as `[object Object]` on narrow screens ([#1312](https://github.com/elastic/eui/pull/1312)) - Fixed `fullWidth` size of `EuiComboBox`, a regression introduced in `4.7.0` ([#1314](https://github.com/elastic/eui/pull/1314)) +- `EuiSuperSelect`, do not set value and defaultValue on input when EuiSuperSelect is passed empty string for `valueOfSelected` prop ([#1319](https://github.com/elastic/eui/pull/1319)) ## [`5.1.0`](https://github.com/elastic/eui/tree/v5.1.0) From 67009d4c95f357b4eb28f1d07d0ef7ba14897085 Mon Sep 17 00:00:00 2001 From: Nathan Reese Date: Mon, 19 Nov 2018 07:56:54 -0700 Subject: [PATCH 3/4] better change log message --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dc0a86eb20f..ec83d8f6048 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ - `EuiBasicTable` now converts the `EuiTableRowCell` `header` into `undefined` if it's been provided as a non-string node, hiding the header and preventing the node from being rendered as `[object Object]` on narrow screens ([#1312](https://github.com/elastic/eui/pull/1312)) - Fixed `fullWidth` size of `EuiComboBox`, a regression introduced in `4.7.0` ([#1314](https://github.com/elastic/eui/pull/1314)) -- `EuiSuperSelect`, do not set value and defaultValue on input when EuiSuperSelect is passed empty string for `valueOfSelected` prop ([#1319](https://github.com/elastic/eui/pull/1319)) +- Fixed error when passing empty string as `value` prop for `EuiSuperSelect` ([#1319](https://github.com/elastic/eui/pull/1319)) ## [`5.1.0`](https://github.com/elastic/eui/tree/v5.1.0) From 00f61b7e043ab75224a28954a15ee5f16cc0d16c Mon Sep 17 00:00:00 2001 From: Nathan Reese Date: Tue, 20 Nov 2018 12:52:27 -0700 Subject: [PATCH 4/4] value == null --- src/components/form/super_select/super_select_control.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/form/super_select/super_select_control.js b/src/components/form/super_select/super_select_control.js index 19a437b9a29..a9130e4ea78 100644 --- a/src/components/form/super_select/super_select_control.js +++ b/src/components/form/super_select/super_select_control.js @@ -33,7 +33,7 @@ export const EuiSuperSelectControl = ({ // React HTML input can not have both value and defaultValue properties. // https://reactjs.org/docs/uncontrolled-components.html#default-values let selectDefaultValue; - if (!value && value !== '') { + if (value == null) { selectDefaultValue = defaultValue || ''; }