From 4599fad75d6d8fbe054eeb7083b4a24cd538cd9a Mon Sep 17 00:00:00 2001 From: afc163 Date: Thu, 17 Sep 2020 17:29:36 +0800 Subject: [PATCH 1/2] fix: compositin status lost when search to open dropdown close ant-design/ant-design#26790 --- examples/single.tsx | 3 +-- src/Selector/SingleSelector.tsx | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/examples/single.tsx b/examples/single.tsx index 237476073..c8f6b9cb0 100644 --- a/examples/single.tsx +++ b/examples/single.tsx @@ -66,7 +66,7 @@ class Test extends React.Component { id="my-select" value={value} placeholder="placeholder" - showSearch={false} + showSearch style={{ width: 500 }} onBlur={this.onBlur} onFocus={this.onFocus} @@ -74,7 +74,6 @@ class Test extends React.Component { allowClear optionFilterProp="text" onChange={this.onChange} - backfill onPopupScroll={() => { console.log('Scroll!'); }} diff --git a/src/Selector/SingleSelector.tsx b/src/Selector/SingleSelector.tsx index 6be9ca255..87c1713b8 100644 --- a/src/Selector/SingleSelector.tsx +++ b/src/Selector/SingleSelector.tsx @@ -40,7 +40,7 @@ const SingleSelector: React.FC = props => { const [inputChanged, setInputChanged] = React.useState(false); const combobox = mode === 'combobox'; - const inputEditable = combobox || (showSearch && open); + const inputEditable = combobox || showSearch; const item = values[0]; let inputValue: string = searchValue || ''; From 3036dd95a47c8b295b982ad190622f267751956e Mon Sep 17 00:00:00 2001 From: afc163 Date: Thu, 17 Sep 2020 17:34:55 +0800 Subject: [PATCH 2/2] Add test case --- tests/Select.test.tsx | 15 +++++++++++++++ tests/__snapshots__/Select.test.tsx.snap | 15 --------------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/tests/Select.test.tsx b/tests/Select.test.tsx index e32342d67..821951051 100644 --- a/tests/Select.test.tsx +++ b/tests/Select.test.tsx @@ -243,6 +243,21 @@ describe('Select.Basic', () => { expect(findSelection(wrapper).text()).toBe('1'); }); + it('search input should be editable initially', () => { + const wrapper = mount( + , + ); + expect( + wrapper + .find('input') + .getDOMNode() + .getAttribute('readonly'), + ).toBeFalsy(); + }); + it('filter options by "value" prop by default', () => { const wrapper = mount(