Reset state before firing onChange in SelectControl (https://github.com/woocommerce/woocommerce-admin/pull/3255)

This commit is contained in:
Joshua T Flowers 2019-11-18 09:23:26 +08:00 committed by GitHub
parent e060fbee56
commit 81567875c0
1 changed files with 2 additions and 2 deletions

View File

@ -94,6 +94,8 @@ export class SelectControl extends Component {
const { query } = this.state;
const newSelected = multiple ? [ ...selected, option ] : [ option ];
this.reset( newSelected );
// Trigger a change if the selected value is different and pass back
// an array or string depending on the original value.
if ( Array.isArray( selected ) ) {
@ -104,8 +106,6 @@ export class SelectControl extends Component {
} else if ( selected !== option.key ) {
onChange( option.key, query );
}
this.reset( newSelected );
}
decrementSelectedIndex() {