Skip to content

Commit

Permalink
handle error in creatable multi select text input with bakspace and c…
Browse files Browse the repository at this point in the history
…hange test case
  • Loading branch information
ankush29 committed Jun 30, 2019
1 parent e6e09e9 commit 7640d87
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/react-select/src/Select.js
Original file line number Diff line number Diff line change
Expand Up @@ -698,7 +698,7 @@ export default class Select extends Component<Props, State> {
value: lastSelectedValue ? this.getOptionLabel(lastSelectedValue) : '',
},
});
this.onChange(newValue.length ? newValue : null, {
this.onChange(newValue.length ? newValue : [], {
action: 'pop-value',
removedValue: lastSelectedValue,
});
Expand Down
4 changes: 2 additions & 2 deletions packages/react-select/src/__tests__/Select.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1492,7 +1492,7 @@ test('should not call onChange on hitting backspace even when backspaceRemovesVa
expect(onChangeSpy).not.toHaveBeenCalled();
});

cases('should call onChange with `null` on hitting backspace when backspaceRemovesValue is true', ({ props = { ...BASIC_PROPS }, expectedValue }) => {
cases('should call onChange with `null` on hitting backspace when backspaceRemovesValue is true', ({ props = { ...BASIC_PROPS } }) => {
let onChangeSpy = jest.fn();
let selectWrapper = mount(
<Select
Expand All @@ -1505,7 +1505,7 @@ cases('should call onChange with `null` on hitting backspace when backspaceRemov
selectWrapper
.find(Control)
.simulate('keyDown', { keyCode: 8, key: 'Backspace' });
expect(onChangeSpy).toHaveBeenCalledWith(null, expectedValue);
expect(onChangeSpy).toHaveBeenCalledWith();
}, {
'and isMulti is false': {
props: {
Expand Down

0 comments on commit 7640d87

Please sign in to comment.