Skip to content

Commit 9edfb76

Browse files
authored
fix: Options with same key (#555)
1 parent a4d44d4 commit 9edfb76

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/utils/valueUtil.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ export function filterOptions(
197197
let filterFunc: FilterFunc<SelectOptionsType[number]>;
198198

199199
if (filterOption === false) {
200-
return options;
200+
return [...options];
201201
}
202202
if (typeof filterOption === 'function') {
203203
filterFunc = filterOption;

tests/Tags.test.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,4 +386,17 @@ describe('Select.Tags', () => {
386386
expect(findSelection(wrapper).text()).toEqual('f');
387387
});
388388
});
389+
390+
it('not modify origin options', () => {
391+
const errSpy = jest.spyOn(console, 'error');
392+
const wrapper = mount(<Select mode="tags" filterOption={false} options={[]} />);
393+
toggleOpen(wrapper);
394+
wrapper.find('input').simulate('change', { target: { value: 'a' } });
395+
wrapper.find('input').simulate('change', { target: { value: 'ab' } });
396+
wrapper.find('input').simulate('change', { target: { value: 'a' } });
397+
wrapper.find('input').simulate('change', { target: { value: '' } });
398+
399+
expect(errSpy).not.toHaveBeenCalled();
400+
errSpy.mockRestore();
401+
});
389402
});

0 commit comments

Comments
 (0)