Skip to content

Commit 32e1861

Browse files
authored
fix: Search focus lost compositing status (#548)
* fix: compositin status lost when search to open dropdown close ant-design/ant-design#26790 * Add test case
1 parent ba94960 commit 32e1861

File tree

4 files changed

+17
-18
lines changed

4 files changed

+17
-18
lines changed

examples/single.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,15 +66,14 @@ class Test extends React.Component {
6666
id="my-select"
6767
value={value}
6868
placeholder="placeholder"
69-
showSearch={false}
69+
showSearch
7070
style={{ width: 500 }}
7171
onBlur={this.onBlur}
7272
onFocus={this.onFocus}
7373
onSearch={this.onSearch}
7474
allowClear
7575
optionFilterProp="text"
7676
onChange={this.onChange}
77-
backfill
7877
onPopupScroll={() => {
7978
console.log('Scroll!');
8079
}}

src/Selector/SingleSelector.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ const SingleSelector: React.FC<SelectorProps> = props => {
4040
const [inputChanged, setInputChanged] = React.useState(false);
4141

4242
const combobox = mode === 'combobox';
43-
const inputEditable = combobox || (showSearch && open);
43+
const inputEditable = combobox || showSearch;
4444
const item = values[0];
4545

4646
let inputValue: string = searchValue || '';

tests/Select.test.tsx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,21 @@ describe('Select.Basic', () => {
243243
expect(findSelection(wrapper).text()).toBe('1');
244244
});
245245

246+
it('search input should be editable initially', () => {
247+
const wrapper = mount(
248+
<Select showSearch>
249+
<Option value="1">One</Option>
250+
<Option value="2">Two</Option>
251+
</Select>,
252+
);
253+
expect(
254+
wrapper
255+
.find('input')
256+
.getDOMNode()
257+
.getAttribute('readonly'),
258+
).toBeFalsy();
259+
});
260+
246261
it('filter options by "value" prop by default', () => {
247262
const wrapper = mount(
248263
<Select showSearch>

tests/__snapshots__/Select.test.tsx.snap

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -254,11 +254,8 @@ exports[`Select.Basic render renders aria-attributes correctly 1`] = `
254254
aria-owns="undefined_list"
255255
autocomplete="off"
256256
class="antd-selection-search-input"
257-
readonly=""
258257
role="combobox"
259-
style="opacity:0"
260258
type="search"
261-
unselectable="on"
262259
value=""
263260
/>
264261
</span>
@@ -312,11 +309,8 @@ exports[`Select.Basic render renders correctly 1`] = `
312309
aria-owns="undefined_list"
313310
autocomplete="off"
314311
class="antd-selection-search-input"
315-
readonly=""
316312
role="combobox"
317-
style="opacity:0"
318313
type="search"
319-
unselectable="on"
320314
value=""
321315
/>
322316
</span>
@@ -372,11 +366,8 @@ exports[`Select.Basic render renders data-attributes correctly 1`] = `
372366
aria-owns="undefined_list"
373367
autocomplete="off"
374368
class="antd-selection-search-input"
375-
readonly=""
376369
role="combobox"
377-
style="opacity:0"
378370
type="search"
379-
unselectable="on"
380371
value=""
381372
/>
382373
</span>
@@ -432,11 +423,8 @@ exports[`Select.Basic render renders disabled select correctly 1`] = `
432423
autocomplete="off"
433424
class="antd-selection-search-input"
434425
disabled=""
435-
readonly=""
436426
role="combobox"
437-
style="opacity:0"
438427
type="search"
439-
unselectable="on"
440428
value=""
441429
/>
442430
</span>
@@ -663,11 +651,8 @@ exports[`Select.Basic render renders role prop correctly 1`] = `
663651
aria-owns="undefined_list"
664652
autocomplete="off"
665653
class="antd-selection-search-input"
666-
readonly=""
667654
role="button"
668-
style="opacity:0"
669655
type="search"
670-
unselectable="on"
671656
value=""
672657
/>
673658
</span>

0 commit comments

Comments
 (0)