From 2a7f5da0c9c0f4a8fedc2cec110a734600dcd387 Mon Sep 17 00:00:00 2001 From: Chandler Prall Date: Mon, 6 Aug 2018 14:27:11 -0600 Subject: [PATCH 1/3] use switch over if...else --- .../form/super_select/super_select.js | 42 +++++++++++-------- 1 file changed, 25 insertions(+), 17 deletions(-) diff --git a/src/components/form/super_select/super_select.js b/src/components/form/super_select/super_select.js index b73efe2747e..a92df04b555 100644 --- a/src/components/form/super_select/super_select.js +++ b/src/components/form/super_select/super_select.js @@ -87,23 +87,31 @@ export class EuiSuperSelect extends Component { } onItemKeyDown = e => { - if (e.keyCode === keyCodes.ESCAPE) { - // close the popover and prevent ancestors from handling - e.preventDefault(); - e.stopPropagation(); - this.closePopover(); - } else if (e.keyCode === keyCodes.TAB) { - // no-op - e.preventDefault(); - e.stopPropagation(); - } else if (e.keyCode === keyCodes.UP) { - e.preventDefault(); - e.stopPropagation(); - this.shiftFocus(SHIFT_BACK); - } else if (e.keyCode === keyCodes.DOWN) { - e.preventDefault(); - e.stopPropagation(); - this.shiftFocus(SHIFT_FORWARD); + switch (e.keyCode) { + case keyCodes.ESCAPE: + // close the popover and prevent ancestors from handling + e.preventDefault(); + e.stopPropagation(); + this.closePopover(); + break; + + case keyCodes.TAB: + // no-op + e.preventDefault(); + e.stopPropagation(); + break; + + case keyCodes.UP: + e.preventDefault(); + e.stopPropagation(); + this.shiftFocus(SHIFT_BACK); + break; + + case keyCodes.DOWN: + e.preventDefault(); + e.stopPropagation(); + this.shiftFocus(SHIFT_FORWARD); + break; } } From 70d08c3c8a9a6406506c419cc1aadc985cfbff76 Mon Sep 17 00:00:00 2001 From: Chandler Prall Date: Wed, 8 Aug 2018 09:55:37 -0600 Subject: [PATCH 2/3] Convert the hidden
- +
@@ -148,18 +139,10 @@ exports[`EuiSuperSelect props more props are propogated to each option 1`] = `
- +
@@ -223,17 +206,10 @@ exports[`EuiSuperSelect props options are rendered 1`] = `
- +
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 e0af24d19fe..5d31ed5ca0b 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 @@ -2,11 +2,9 @@ exports[`EuiSuperSelectControl is rendered 1`] = ` Array [ - , + ,
@@ -190,9 +181,9 @@ Array [ exports[`EuiSuperSelectControl props fullWidth is rendered 1`] = ` Array [ - , + ,
@@ -377,18 +361,10 @@ Array [ exports[`EuiSuperSelectControl props value option is rendered 1`] = ` Array [ - , + ,
diff --git a/src/components/form/super_select/_super_select_control.scss b/src/components/form/super_select/_super_select_control.scss index b565591ee2b..b32d0e71cf6 100644 --- a/src/components/form/super_select/_super_select_control.scss +++ b/src/components/form/super_select/_super_select_control.scss @@ -28,9 +28,3 @@ @include euiFormControlFocusStyle; } } - -.euiSuperSelectControl__hiddenField { - // This should be completely hidden even from screen readers, - // it's meant only to allow submission of a form. - display: none; -} diff --git a/src/components/form/super_select/super_select_control.js b/src/components/form/super_select/super_select_control.js index dd58ad685f8..00bf41066cd 100644 --- a/src/components/form/super_select/super_select_control.js +++ b/src/components/form/super_select/super_select_control.js @@ -13,10 +13,8 @@ export const EuiSuperSelectControl = ({ options, id, name, - inputRef, fullWidth, isLoading, - hasNoInitialSelection, defaultValue, compressed, value, @@ -32,13 +30,6 @@ export const EuiSuperSelectControl = ({ className ); - let emptyOptionNode; - if (hasNoInitialSelection) { - emptyOptionNode = ( - - ); - } - // React HTML input can not have both value and defaultValue properties. // https://reactjs.org/docs/uncontrolled-components.html#default-values let selectDefaultValue; @@ -61,25 +52,13 @@ export const EuiSuperSelectControl = ({ return ( - + />