Skip to content

Commit

Permalink
Change
Browse files Browse the repository at this point in the history
  • Loading branch information
Methuselah96 committed Dec 18, 2020
1 parent fcdeb2b commit ffb4740
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions packages/react-select/src/Select.js
Original file line number Diff line number Diff line change
Expand Up @@ -685,10 +685,15 @@ export default class Select extends Component<Props, State> {
const { isMulti } = this.props;
const { selectValue } = this.state;
const candidate = this.getOptionValue(removedValue);
const newValue = selectValue.filter(
const filteredValue = selectValue.filter(
i => this.getOptionValue(i) !== candidate
);
this.onChange(isMulti ? newValue : null, {
const newValue = isMulti
? filteredValue
: filteredValue.length > 0
? filteredValue[0]
: null;
this.onChange(newValue, {
action: 'remove-value',
removedValue,
});
Expand All @@ -708,7 +713,12 @@ export default class Select extends Component<Props, State> {
const { isMulti } = this.props;
const { selectValue } = this.state;
const lastSelectedValue = selectValue[selectValue.length - 1];
const newValue = selectValue.slice(0, selectValue.length - 1);
const slicedValue = selectValue.slice(0, selectValue.length - 1);
const newValue = isMulti
? slicedValue
: slicedValue.length > 0
? slicedValue[0]
: null;
this.announceAriaLiveSelection({
event: 'pop-value',
context: {
Expand Down

0 comments on commit ffb4740

Please sign in to comment.