Fix selected value showing for multiple SelectControl (https://github.com/woocommerce/woocommerce-admin/pull/3254)

This commit is contained in:
Joshua T Flowers 2019-11-18 09:23:15 +08:00 committed by GitHub
parent 03399a034c
commit e060fbee56
1 changed files with 9 additions and 3 deletions

View File

@ -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() {