From e060fbee56430d6bb3cdff43e92a1560f729525d Mon Sep 17 00:00:00 2001 From: Joshua T Flowers Date: Mon, 18 Nov 2019 09:23:15 +0800 Subject: [PATCH] Fix selected value showing for multiple SelectControl (https://github.com/woocommerce/woocommerce-admin/pull/3254) --- .../components/src/select-control/control.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/plugins/woocommerce-admin/packages/components/src/select-control/control.js b/plugins/woocommerce-admin/packages/components/src/select-control/control.js index a0d61d0df9e..40235f7a275 100644 --- a/plugins/woocommerce-admin/packages/components/src/select-control/control.js +++ b/plugins/woocommerce-admin/packages/components/src/select-control/control.js @@ -137,11 +137,17 @@ class Control extends Component { const { isFocused, isSearchable, multiple, query, selected } = this.props; const selectedValue = selected.length ? selected[ 0 ].label : ''; - if ( ! isSearchable && multiple ) { - return ''; + // Show the selected value for simple select dropdowns. + if ( ! multiple && ! isFocused ) { + return selectedValue; } - return isSearchable && isFocused ? query : selectedValue; + // Show the search query when focused on searchable controls. + if ( isSearchable && isFocused ) { + return query; + } + + return ''; } render() {