diff --git a/src/Select.jsx b/src/Select.jsx index 0ab5a02b9..2e936b481 100644 --- a/src/Select.jsx +++ b/src/Select.jsx @@ -572,11 +572,13 @@ const Select = React.createClass({ }); }, setInputValue(inputValue, fireSearch = true) { - this.setState({ - inputValue, - }); - if (fireSearch) { - this.props.onSearch(inputValue); + if (inputValue !== this.state.inputValue) { + this.setState({ + inputValue, + }); + if (fireSearch) { + this.props.onSearch(inputValue); + } } }, clearBlurTime() { diff --git a/tests/Select.spec.js b/tests/Select.spec.js index bc9aa5ac5..f4a7b9078 100644 --- a/tests/Select.spec.js +++ b/tests/Select.spec.js @@ -241,6 +241,23 @@ describe('Select', () => { expect(handleSearch).toBeCalledWith('1'); }); + it('not fires search event when user select', () => { + const handleSearch = jest.fn(); + const wrapper = mount( + + ); + wrapper.find('.rc-select').simulate('click'); + const dropdownWrapper = mount(wrapper.find('Trigger').node.getComponent()); + dropdownWrapper.find('MenuItem').first().simulate('click'); + expect(handleSearch).not.toBeCalled(); + }); + describe('focus', () => { let handleFocus; let wrapper;