Skip to content

Commit 5597ec0

Browse files
committed
fix: auto-complete select tab focus logic #1438 #3015
1 parent f26c021 commit 5597ec0

File tree

5 files changed

+22
-18
lines changed

5 files changed

+22
-18
lines changed

components/auto-complete/__tests__/__snapshots__/demo.test.js.snap

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

33
exports[`renders ./antdv-demo/docs/auto-complete/demo/basic.md correctly 1`] = `
4-
<div tabindex="0" class="ant-select ant-select-combobox ant-select-enabled ant-select-show-search ant-select-auto-complete" style="width: 200px;">
4+
<div tabindex="-1" class="ant-select ant-select-combobox ant-select-enabled ant-select-show-search ant-select-auto-complete" style="width: 200px;">
55
<div role="combobox" aria-autocomplete="list" aria-haspopup="true" aria-controls="test-uuid" class="ant-select-selection ant-select-selection--single">
66
<div class="ant-select-selection__rendered">
77
<ul>
@@ -16,7 +16,7 @@ exports[`renders ./antdv-demo/docs/auto-complete/demo/basic.md correctly 1`] = `
1616
1717
exports[`renders ./antdv-demo/docs/auto-complete/demo/certain-category.md correctly 1`] = `
1818
<div class="certain-category-search-wrapper" style="width: 250px;">
19-
<div tabindex="0" class="certain-category-search ant-select ant-select-combobox ant-select-enabled ant-select-lg ant-select-lg ant-select-show-search ant-select-auto-complete" style="width: 100%;">
19+
<div tabindex="-1" class="certain-category-search ant-select ant-select-combobox ant-select-enabled ant-select-lg ant-select-lg ant-select-show-search ant-select-auto-complete" style="width: 100%;">
2020
<div role="combobox" aria-autocomplete="list" aria-haspopup="true" aria-controls="test-uuid" class="ant-select-selection ant-select-selection--single">
2121
<div class="ant-select-selection__rendered">
2222
<ul>
@@ -31,7 +31,7 @@ exports[`renders ./antdv-demo/docs/auto-complete/demo/certain-category.md correc
3131
`;
3232
3333
exports[`renders ./antdv-demo/docs/auto-complete/demo/custom.md correctly 1`] = `
34-
<div tabindex="0" class="ant-select ant-select-combobox ant-select-enabled ant-select-show-search ant-select-auto-complete" style="width: 200px;">
34+
<div tabindex="-1" class="ant-select ant-select-combobox ant-select-enabled ant-select-show-search ant-select-auto-complete" style="width: 200px;">
3535
<div role="combobox" aria-autocomplete="list" aria-haspopup="true" aria-controls="test-uuid" class="ant-select-selection ant-select-selection--single">
3636
<div class="ant-select-selection__rendered">
3737
<ul>
@@ -45,7 +45,7 @@ exports[`renders ./antdv-demo/docs/auto-complete/demo/custom.md correctly 1`] =
4545
`;
4646
4747
exports[`renders ./antdv-demo/docs/auto-complete/demo/non-case-sensitive.md correctly 1`] = `
48-
<div tabindex="0" class="ant-select ant-select-combobox ant-select-enabled ant-select-show-search ant-select-auto-complete" style="width: 200px;">
48+
<div tabindex="-1" class="ant-select ant-select-combobox ant-select-enabled ant-select-show-search ant-select-auto-complete" style="width: 200px;">
4949
<div role="combobox" aria-autocomplete="list" aria-haspopup="true" aria-controls="test-uuid" class="ant-select-selection ant-select-selection--single">
5050
<div class="ant-select-selection__rendered">
5151
<ul>
@@ -59,7 +59,7 @@ exports[`renders ./antdv-demo/docs/auto-complete/demo/non-case-sensitive.md corr
5959
`;
6060
6161
exports[`renders ./antdv-demo/docs/auto-complete/demo/options.md correctly 1`] = `
62-
<div tabindex="0" class="ant-select ant-select-combobox ant-select-enabled ant-select-show-search ant-select-auto-complete" style="width: 200px;">
62+
<div tabindex="-1" class="ant-select ant-select-combobox ant-select-enabled ant-select-show-search ant-select-auto-complete" style="width: 200px;">
6363
<div role="combobox" aria-autocomplete="list" aria-haspopup="true" aria-controls="test-uuid" class="ant-select-selection ant-select-selection--single">
6464
<div class="ant-select-selection__rendered">
6565
<ul>
@@ -74,7 +74,7 @@ exports[`renders ./antdv-demo/docs/auto-complete/demo/options.md correctly 1`] =
7474
7575
exports[`renders ./antdv-demo/docs/auto-complete/demo/uncertain-category.md correctly 1`] = `
7676
<div class="global-search-wrapper" style="width: 300px;">
77-
<div tabindex="0" class="global-search ant-select ant-select-combobox ant-select-enabled ant-select-lg ant-select-lg ant-select-show-search ant-select-auto-complete" style="width: 100%;">
77+
<div tabindex="-1" class="global-search ant-select ant-select-combobox ant-select-enabled ant-select-lg ant-select-lg ant-select-show-search ant-select-auto-complete" style="width: 100%;">
7878
<div role="combobox" aria-autocomplete="list" aria-haspopup="true" aria-controls="test-uuid" class="ant-select-selection ant-select-selection--single">
7979
<div class="ant-select-selection__rendered">
8080
<ul>

components/form/__tests__/__snapshots__/demo.test.js.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ exports[`renders ./antdv-demo/docs/form/demo/register.vue correctly 1`] = `
414414
<div class="ant-row ant-form-item">
415415
<div class="ant-col ant-col-xs-24 ant-col-sm-8 ant-form-item-label"><label for="register_website" title="Website" class="ant-form-item-required">Website</label></div>
416416
<div class="ant-col ant-col-xs-24 ant-col-sm-16 ant-form-item-control-wrapper">
417-
<div class="ant-form-item-control"><span class="ant-form-item-children"><div tabindex="0" class="ant-select ant-select-combobox ant-select-enabled ant-select-show-search ant-select-auto-complete" data-__meta="[object Object]" data-__field="[object Object]" id="register_website"><div role="combobox" aria-autocomplete="list" aria-haspopup="true" aria-controls="test-uuid" class="ant-select-selection ant-select-selection--single"><div class="ant-select-selection__rendered"><ul><li class="ant-select-search ant-select-search--inline"><div class="ant-select-search__field__wrap"><input placeholder="website" type="text" value="" class="ant-input ant-select-search__field"><span class="ant-select-search__field__mirror">&nbsp;</span></div>
417+
<div class="ant-form-item-control"><span class="ant-form-item-children"><div tabindex="-1" class="ant-select ant-select-combobox ant-select-enabled ant-select-show-search ant-select-auto-complete" data-__meta="[object Object]" data-__field="[object Object]" id="register_website"><div role="combobox" aria-autocomplete="list" aria-haspopup="true" aria-controls="test-uuid" class="ant-select-selection ant-select-selection--single"><div class="ant-select-selection__rendered"><ul><li class="ant-select-search ant-select-search--inline"><div class="ant-select-search__field__wrap"><input placeholder="website" type="text" value="" class="ant-input ant-select-search__field"><span class="ant-select-search__field__mirror">&nbsp;</span></div>
418418
</li>
419419
</ul>
420420
</div><span unselectable="on" class="ant-select-arrow" style="user-select: none;"><i aria-label="icon: down" class="anticon anticon-down ant-select-arrow-icon"><svg viewBox="64 64 896 896" data-icon="down" width="1em" height="1em" fill="currentColor" aria-hidden="true" focusable="false" class=""><path d="M884 256h-75c-5.1 0-9.9 2.5-12.9 6.6L512 654.2 227.9 262.6c-3-4.1-7.8-6.6-12.9-6.6h-75c-6.5 0-10.3 7.4-6.5 12.7l352.6 486.1c12.8 17.6 39 17.6 51.7 0l352.6-486.1c3.9-5.3.1-12.7-6.4-12.7z"></path></svg></i></span>
@@ -539,7 +539,7 @@ exports[`renders ./antdv-demo/docs/form/demo/validate-other.vue correctly 1`] =
539539
<div class="ant-row ant-form-item">
540540
<div class="ant-col ant-col-6 ant-form-item-label"><label for="validate_other_select-multiple" title="Select[multiple]" class="ant-form-item-required">Select[multiple]</label></div>
541541
<div class="ant-col ant-col-14 ant-form-item-control-wrapper">
542-
<div class="ant-form-item-control"><span class="ant-form-item-children"><div tabindex="0" class="ant-select ant-select-enabled" data-__meta="[object Object]" data-__field="[object Object]" id="validate_other_select-multiple"><div role="combobox" aria-autocomplete="list" aria-haspopup="true" aria-controls="test-uuid" class="ant-select-selection ant-select-selection--multiple"><div class="ant-select-selection__rendered"><div unselectable="on" class="ant-select-selection__placeholder" style="display: block; user-select: none;">Please select favourite colors</div><div><li class="ant-select-search ant-select-search--inline"><div class="ant-select-search__field__wrap"><input autocomplete="off" value="" class="ant-select-search__field"><span class="ant-select-search__field__mirror">&nbsp;</span></div>
542+
<div class="ant-form-item-control"><span class="ant-form-item-children"><div tabindex="-1" class="ant-select ant-select-enabled" data-__meta="[object Object]" data-__field="[object Object]" id="validate_other_select-multiple"><div role="combobox" aria-autocomplete="list" aria-haspopup="true" aria-controls="test-uuid" class="ant-select-selection ant-select-selection--multiple"><div class="ant-select-selection__rendered"><div unselectable="on" class="ant-select-selection__placeholder" style="display: block; user-select: none;">Please select favourite colors</div><div><li class="ant-select-search ant-select-search--inline"><div class="ant-select-search__field__wrap"><input autocomplete="off" value="" class="ant-select-search__field"><span class="ant-select-search__field__mirror">&nbsp;</span></div>
543543
</li>
544544
</div>
545545
</div>

components/input/__tests__/__snapshots__/demo.test.js.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ exports[`renders ./antdv-demo/docs/input/demo/group.md correctly 1`] = `
5151
Sign Up
5252
</div></div><span unselectable="on" class="ant-select-arrow" style="user-select: none;"><i aria-label="icon: down" class="anticon anticon-down ant-select-arrow-icon"><svg viewBox="64 64 896 896" data-icon="down" width="1em" height="1em" fill="currentColor" aria-hidden="true" focusable="false" class=""><path d="M884 256h-75c-5.1 0-9.9 2.5-12.9 6.6L512 654.2 227.9 262.6c-3-4.1-7.8-6.6-12.9-6.6h-75c-6.5 0-10.3 7.4-6.5 12.7l352.6 486.1c12.8 17.6 39 17.6 51.7 0l352.6-486.1c3.9-5.3.1-12.7-6.4-12.7z"></path></svg></i></span></div>
5353
</div>
54-
<div tabindex="0" class="ant-select ant-select-combobox ant-select-enabled ant-select-show-search ant-select-auto-complete" style="width: 200px;">
54+
<div tabindex="-1" class="ant-select ant-select-combobox ant-select-enabled ant-select-show-search ant-select-auto-complete" style="width: 200px;">
5555
<div role="combobox" aria-autocomplete="list" aria-haspopup="true" aria-controls="test-uuid" class="ant-select-selection ant-select-selection--single">
5656
<div class="ant-select-selection__rendered">
5757
<ul>

components/select/__tests__/__snapshots__/demo.test.js.snap

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

33
exports[`renders ./antdv-demo/docs/select/demo/automatic-tokenization.md correctly 1`] = `
4-
<div tabindex="0" class="ant-select ant-select-enabled" style="width: 100%;">
4+
<div tabindex="-1" class="ant-select ant-select-enabled" style="width: 100%;">
55
<div role="combobox" aria-autocomplete="list" aria-haspopup="true" aria-controls="test-uuid" class="ant-select-selection ant-select-selection--multiple">
66
<div class="ant-select-selection__rendered">
77
<div>
@@ -82,7 +82,7 @@ exports[`renders ./antdv-demo/docs/select/demo/custom-dropdown-menu.md correctly
8282
`;
8383
8484
exports[`renders ./antdv-demo/docs/select/demo/hide-selected.md correctly 1`] = `
85-
<div tabindex="0" class="ant-select ant-select-enabled" style="width: 100%;">
85+
<div tabindex="-1" class="ant-select ant-select-enabled" style="width: 100%;">
8686
<div role="combobox" aria-autocomplete="list" aria-haspopup="true" aria-controls="test-uuid" class="ant-select-selection ant-select-selection--multiple">
8787
<div class="ant-select-selection__rendered">
8888
<div unselectable="on" class="ant-select-selection__placeholder" style="display: block; user-select: none;">Inserted are removed</div>
@@ -109,7 +109,7 @@ exports[`renders ./antdv-demo/docs/select/demo/label-in-value.md correctly 1`] =
109109
`;
110110
111111
exports[`renders ./antdv-demo/docs/select/demo/multiple.md correctly 1`] = `
112-
<div tabindex="0" class="ant-select ant-select-enabled" style="width: 100%;">
112+
<div tabindex="-1" class="ant-select ant-select-enabled" style="width: 100%;">
113113
<div role="combobox" aria-autocomplete="list" aria-haspopup="true" aria-controls="test-uuid" class="ant-select-selection ant-select-selection--multiple">
114114
<div class="ant-select-selection__rendered">
115115
<div unselectable="on" class="ant-select-selection__placeholder" style="display: none; user-select: none;">Please select</div>
@@ -146,7 +146,7 @@ exports[`renders ./antdv-demo/docs/select/demo/optgroup.md correctly 1`] = `
146146
`;
147147
148148
exports[`renders ./antdv-demo/docs/select/demo/option-label-prop.md correctly 1`] = `
149-
<div tabindex="0" class="ant-select ant-select-enabled" style="width: 100%;">
149+
<div tabindex="-1" class="ant-select ant-select-enabled" style="width: 100%;">
150150
<div role="combobox" aria-autocomplete="list" aria-haspopup="true" aria-controls="test-uuid" class="ant-select-selection ant-select-selection--multiple">
151151
<div class="ant-select-selection__rendered">
152152
<div unselectable="on" class="ant-select-selection__placeholder" style="display: none; user-select: none;">select one country</div>
@@ -200,7 +200,7 @@ exports[`renders ./antdv-demo/docs/select/demo/search-box.md correctly 1`] = `
200200
`;
201201
202202
exports[`renders ./antdv-demo/docs/select/demo/select-users.md correctly 1`] = `
203-
<div tabindex="0" class="ant-select ant-select-enabled" style="width: 100%;">
203+
<div tabindex="-1" class="ant-select ant-select-enabled" style="width: 100%;">
204204
<div role="combobox" aria-autocomplete="list" aria-haspopup="true" aria-controls="test-uuid" class="ant-select-selection ant-select-selection--multiple">
205205
<div class="ant-select-selection__rendered">
206206
<div unselectable="on" class="ant-select-selection__placeholder" style="display: block; user-select: none;">Select users</div>
@@ -232,7 +232,7 @@ exports[`renders ./antdv-demo/docs/select/demo/size.md correctly 1`] = `
232232
</div><span unselectable="on" class="ant-select-arrow" style="user-select: none;"><i aria-label="icon: down" class="anticon anticon-down ant-select-arrow-icon"><svg viewBox="64 64 896 896" data-icon="down" width="1em" height="1em" fill="currentColor" aria-hidden="true" focusable="false" class=""><path d="M884 256h-75c-5.1 0-9.9 2.5-12.9 6.6L512 654.2 227.9 262.6c-3-4.1-7.8-6.6-12.9-6.6h-75c-6.5 0-10.3 7.4-6.5 12.7l352.6 486.1c12.8 17.6 39 17.6 51.7 0l352.6-486.1c3.9-5.3.1-12.7-6.4-12.7z"></path></svg></i></span>
233233
</div>
234234
</div> <br>
235-
<div tabindex="0" class="ant-select ant-select-enabled" style="width: 200px;">
235+
<div tabindex="-1" class="ant-select ant-select-enabled" style="width: 200px;">
236236
<div role="combobox" aria-autocomplete="list" aria-haspopup="true" aria-controls="test-uuid" class="ant-select-selection ant-select-selection--multiple">
237237
<div class="ant-select-selection__rendered">
238238
<div unselectable="on" class="ant-select-selection__placeholder" style="display: none; user-select: none;">Please select</div>
@@ -254,7 +254,7 @@ exports[`renders ./antdv-demo/docs/select/demo/size.md correctly 1`] = `
254254
</div>
255255
</div>
256256
</div> <br>
257-
<div tabindex="0" class="ant-select ant-select-enabled" style="width: 200px;">
257+
<div tabindex="-1" class="ant-select ant-select-enabled" style="width: 200px;">
258258
<div role="combobox" aria-autocomplete="list" aria-haspopup="true" aria-controls="test-uuid" class="ant-select-selection ant-select-selection--multiple">
259259
<div class="ant-select-selection__rendered">
260260
<div unselectable="on" class="ant-select-selection__placeholder" style="display: none; user-select: none;">Please select</div>
@@ -303,7 +303,7 @@ exports[`renders ./antdv-demo/docs/select/demo/suffix.md correctly 1`] = `
303303
`;
304304
305305
exports[`renders ./antdv-demo/docs/select/demo/tags.md correctly 1`] = `
306-
<div tabindex="0" class="ant-select ant-select-enabled" style="width: 100%;">
306+
<div tabindex="-1" class="ant-select ant-select-enabled" style="width: 100%;">
307307
<div role="combobox" aria-autocomplete="list" aria-haspopup="true" aria-controls="test-uuid" class="ant-select-selection ant-select-selection--multiple">
308308
<div class="ant-select-selection__rendered">
309309
<div unselectable="on" class="ant-select-selection__placeholder" style="display: block; user-select: none;">Tags Mode</div>

components/vc-select/Select.jsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1624,6 +1624,10 @@ const Select = {
16241624
// selectionProps.on.blur = this.selectionRefBlur;
16251625
// selectionProps.attrs.tabIndex = props.disabled ? -1 : props.tabIndex;
16261626
//}
1627+
let extraSelectionProps = { attrs: { tabIndex: -1 } };
1628+
if (!isMultipleOrTagsOrCombobox(props)) {
1629+
extraSelectionProps.attrs.tabIndex = props.disabled ? -1 : props.tabIndex;
1630+
}
16271631
const rootCls = {
16281632
[prefixCls]: true,
16291633
[`${prefixCls}-open`]: open,
@@ -1692,7 +1696,7 @@ const Select = {
16921696
onMousedown={this.markMouseDown}
16931697
onMouseup={this.markMouseLeave}
16941698
onMouseout={this.markMouseLeave}
1695-
tabIndex={props.disabled ? -1 : props.tabIndex}
1699+
{...extraSelectionProps}
16961700
onBlur={this.selectionRefBlur}
16971701
onFocus={this.selectionRefFocus}
16981702
onClick={this.selectionRefClick}

0 commit comments

Comments
 (0)