Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ const Select = React.forwardRef(
? {
label: option?.[mergedFieldNames.label],
value: val,
key: option.key ?? val,
key: option?.key ?? val,
}
: val,
injectPropsWithOption(option),
Expand Down
21 changes: 21 additions & 0 deletions tests/Multiple.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,27 @@ describe('Select.Multiple', () => {
expect(wrapper.exists('.rc-select-selection-item-remove')).toBeFalsy();
});

it('do not crash if value not in options when removing option', () => {
const wrapper = mount(
<Select
defaultValue={[
{
label: 'value not in options',
value: 'value-not-in-options',
},
]}
mode="multiple"
labelInValue
>
<Option value={1}>1</Option>
<Option value={2}>2</Option>
</Select>,
);
expect(findSelection(wrapper, 0).text()).toEqual('value not in options');
removeSelection(wrapper, 0);
expect(wrapper.find('Selector').props().values.length).toEqual(0);
});

describe('optionLabelProp', () => {
it('basic', () => {
const wrapper = mount(
Expand Down