From e5ac631168366582ef02d6e788d3d1f8c7779dcc Mon Sep 17 00:00:00 2001 From: RaoHai Date: Thu, 9 Feb 2017 11:09:21 +0800 Subject: [PATCH] Fix onFocus of multiple select + close #https://github.com/ant-design/ant-design/issues/4808 --- examples/multiple.js | 1 + src/Select.jsx | 2 +- tests/Select.multiple.spec.js | 16 ++++++++++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/examples/multiple.js b/examples/multiple.js index 761fe38b8..2f0c39bc3 100644 --- a/examples/multiple.js +++ b/examples/multiple.js @@ -70,6 +70,7 @@ const Test = React.createClass({ onDeselect={onDeselect} placeholder="please select" onChange={this.onChange} + onFocus={() => console.log('focus')} tokenSeparators={[' ', ',']} > {children} diff --git a/src/Select.jsx b/src/Select.jsx index fea251571..8cd48e756 100644 --- a/src/Select.jsx +++ b/src/Select.jsx @@ -339,7 +339,7 @@ const Select = React.createClass({ }, onOuterFocus(e) { - if (e.target === this.getInputDOMNode()) { + if (!isMultipleOrTagsOrCombobox(this.props) && e.target === this.getInputDOMNode()) { return; } this.clearBlurTime(); diff --git a/tests/Select.multiple.spec.js b/tests/Select.multiple.spec.js index 007354b29..0a5cc0fb3 100644 --- a/tests/Select.multiple.spec.js +++ b/tests/Select.multiple.spec.js @@ -49,4 +49,20 @@ describe('Select.multiple', () => { expect(wrapper.state().open).toBe(false); expect(input.node.focus).toBeCalled(); }); + + it('focus', () => { + const handleFocus = jest.fn(); + const wrapper = mount( + , + ); + wrapper.find('div').first().simulate('focus'); + it('fires focus event', () => { + expect(handleFocus).toBeCalled(); + }); + }); });