Skip to content

Commit 82c82fa

Browse files
committed
Remove style changes
1 parent 0205067 commit 82c82fa

File tree

2 files changed

+48
-50
lines changed

2 files changed

+48
-50
lines changed

packages/react-select/src/Select.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -685,13 +685,13 @@ 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 filteredValue = selectValue.filter(
688+
const newValues = selectValue.filter(
689689
i => this.getOptionValue(i) !== candidate
690690
);
691691
const newValue = isMulti
692-
? filteredValue
693-
: filteredValue.length > 0
694-
? filteredValue[0]
692+
? newValues
693+
: newValues.length > 0
694+
? newValues[0]
695695
: null;
696696
this.onChange(newValue, {
697697
action: 'remove-value',
@@ -713,11 +713,11 @@ export default class Select extends Component<Props, State> {
713713
const { isMulti } = this.props;
714714
const { selectValue } = this.state;
715715
const lastSelectedValue = selectValue[selectValue.length - 1];
716-
const slicedValue = selectValue.slice(0, selectValue.length - 1);
716+
const newValues = selectValue.slice(0, selectValue.length - 1);
717717
const newValue = isMulti
718-
? slicedValue
719-
: slicedValue.length > 0
720-
? slicedValue[0]
718+
? newValues
719+
: newValues.length > 0
720+
? newValues[0]
721721
: null;
722722
this.announceAriaLiveSelection({
723723
event: 'pop-value',

packages/react-select/src/__tests__/Select.test.js

Lines changed: 40 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1643,48 +1643,46 @@ test('should not call onChange on hitting backspace even when backspaceRemovesVa
16431643
expect(onChangeSpy).not.toHaveBeenCalled();
16441644
});
16451645

1646-
cases(
1647-
'should call onChange with `null` on hitting backspace when backspaceRemovesValue is true',
1648-
({ props = { ...BASIC_PROPS }, expectedValue }) => {
1649-
let onChangeSpy = jest.fn();
1650-
let { container } = render(
1651-
<Select
1652-
{...props}
1653-
backspaceRemovesValue
1654-
isClearable
1655-
onChange={onChangeSpy}
1656-
/>
1657-
);
1658-
fireEvent.keyDown(container.querySelector('.react-select__control'), {
1659-
keyCode: 8,
1660-
key: 'Backspace',
1661-
});
1662-
expect(onChangeSpy).toHaveBeenCalledWith(null, expectedValue);
1663-
},
1664-
{
1665-
'and isMulti is false': {
1666-
props: {
1667-
...BASIC_PROPS,
1668-
isMulti: false,
1669-
},
1670-
expectedValue: {
1671-
action: 'clear',
1672-
name: 'test-input-name',
1673-
},
1674-
},
1675-
'and isMulti is true': {
1676-
props: {
1677-
...BASIC_PROPS,
1678-
isMulti: true,
1679-
},
1680-
expectedValue: {
1681-
action: 'pop-value',
1682-
name: 'test-input-name',
1683-
removedValue: undefined,
1684-
},
1685-
},
1686-
}
1687-
);
1646+
test('should call onChange with `null` on hitting backspace when backspaceRemovesValue is true and isMulti is false', () => {
1647+
let onChangeSpy = jest.fn();
1648+
let selectWrapper = mount(
1649+
<Select
1650+
{...BASIC_PROPS}
1651+
backspaceRemovesValue
1652+
isClearable
1653+
isMulti={false}
1654+
onChange={onChangeSpy}
1655+
/>
1656+
);
1657+
selectWrapper
1658+
.find(Control)
1659+
.simulate('keyDown', { keyCode: 8, key: 'Backspace' });
1660+
expect(onChangeSpy).toHaveBeenCalledWith(null, {
1661+
action: 'clear',
1662+
name: 'test-input-name',
1663+
});
1664+
});
1665+
1666+
test('should call onChange with an array on hitting backspace when backspaceRemovesValue is true and isMulti is true', () => {
1667+
let onChangeSpy = jest.fn();
1668+
let selectWrapper = mount(
1669+
<Select
1670+
{...BASIC_PROPS}
1671+
backspaceRemovesValue
1672+
isClearable
1673+
isMulti
1674+
onChange={onChangeSpy}
1675+
/>
1676+
);
1677+
selectWrapper
1678+
.find(Control)
1679+
.simulate('keyDown', { keyCode: 8, key: 'Backspace' });
1680+
expect(onChangeSpy).toHaveBeenCalledWith([], {
1681+
action: 'pop-value',
1682+
name: 'test-input-name',
1683+
removedValue: undefined,
1684+
});
1685+
});
16881686

16891687
test('multi select > clicking on X next to option will call onChange with all options other that the clicked option', () => {
16901688
let onChangeSpy = jest.fn();

0 commit comments

Comments
 (0)