diff --git a/src/Select.jsx b/src/Select.jsx index 48c143691..d336ce1bb 100644 --- a/src/Select.jsx +++ b/src/Select.jsx @@ -890,12 +890,20 @@ export default class Select extends React.Component { ); if (inputValue) { const notFindInputItem = sel.every(option => { - return !this.filterOption.call( - this, - inputValue, - option, - () => getValuePropValue(option) === inputValue - ); + // this.filterOption return true has two meaning, + // 1, some one exists after filtering + // 2, filterOption is set to false + // condition 2 does not mean the option has same value with inputValue + const filterFn = () => getValuePropValue(option) === inputValue; + if (this.props.filterOption !== false) { + return !this.filterOption.call( + this, + inputValue, + option, + filterFn + ); + } + return !filterFn(); }); if (notFindInputItem) { sel.unshift( diff --git a/tests/Select.tags.spec.js b/tests/Select.tags.spec.js index 8b98e2665..20cc8c79b 100644 --- a/tests/Select.tags.spec.js +++ b/tests/Select.tags.spec.js @@ -92,4 +92,23 @@ describe('Select.tags', () => { expect(wrapper).toMatchSnapshot(); }); + + it('filterOption is false', () => { + const wrapper = mount( + , + ); + const input = wrapper.find('input'); + input.node.focus = jest.fn(); + input + .simulate('change', { target: { value: 'a' } }) + .simulate('keyDown', { keyCode: KeyCode.ENTER }); + + expect(wrapper.state().value).toEqual([{ key: 'a', label: 'a', title: undefined }]); + }); });