Skip to content

Commit

Permalink
fix: Options with same key (#555)
Browse files Browse the repository at this point in the history
  • Loading branch information
zombieJ committed Oct 8, 2020
1 parent a4d44d4 commit 9edfb76
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/utils/valueUtil.ts
Expand Up @@ -197,7 +197,7 @@ export function filterOptions(
let filterFunc: FilterFunc<SelectOptionsType[number]>;

if (filterOption === false) {
return options;
return [...options];
}
if (typeof filterOption === 'function') {
filterFunc = filterOption;
Expand Down
13 changes: 13 additions & 0 deletions tests/Tags.test.tsx
Expand Up @@ -386,4 +386,17 @@ describe('Select.Tags', () => {
expect(findSelection(wrapper).text()).toEqual('f');
});
});

it('not modify origin options', () => {
const errSpy = jest.spyOn(console, 'error');
const wrapper = mount(<Select mode="tags" filterOption={false} options={[]} />);
toggleOpen(wrapper);
wrapper.find('input').simulate('change', { target: { value: 'a' } });
wrapper.find('input').simulate('change', { target: { value: 'ab' } });
wrapper.find('input').simulate('change', { target: { value: 'a' } });
wrapper.find('input').simulate('change', { target: { value: '' } });

expect(errSpy).not.toHaveBeenCalled();
errSpy.mockRestore();
});
});

1 comment on commit 9edfb76

@vercel
Copy link

@vercel vercel bot commented on 9edfb76 Oct 8, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.