Skip to content

Commit ffb4740

Browse files
committed
Change
1 parent fcdeb2b commit ffb4740

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

packages/react-select/src/Select.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -685,10 +685,15 @@ export default class Select extends Component<Props, State> {
685685
const { isMulti } = this.props;
686686
const { selectValue } = this.state;
687687
const candidate = this.getOptionValue(removedValue);
688-
const newValue = selectValue.filter(
688+
const filteredValue = selectValue.filter(
689689
i => this.getOptionValue(i) !== candidate
690690
);
691-
this.onChange(isMulti ? newValue : null, {
691+
const newValue = isMulti
692+
? filteredValue
693+
: filteredValue.length > 0
694+
? filteredValue[0]
695+
: null;
696+
this.onChange(newValue, {
692697
action: 'remove-value',
693698
removedValue,
694699
});
@@ -708,7 +713,12 @@ export default class Select extends Component<Props, State> {
708713
const { isMulti } = this.props;
709714
const { selectValue } = this.state;
710715
const lastSelectedValue = selectValue[selectValue.length - 1];
711-
const newValue = selectValue.slice(0, selectValue.length - 1);
716+
const slicedValue = selectValue.slice(0, selectValue.length - 1);
717+
const newValue = isMulti
718+
? slicedValue
719+
: slicedValue.length > 0
720+
? slicedValue[0]
721+
: null;
712722
this.announceAriaLiveSelection({
713723
event: 'pop-value',
714724
context: {

0 commit comments

Comments
 (0)