Skip to content

Commit f7b2322

Browse files
authored
fix: Input type search (#538)
* fix: input should be type="search" prevent autocomplete to be shown in Chromium close #469 close ant-design/ant-design#18808 * test: update snapshot * remove search-cancel-button style * update history
1 parent 9e8b782 commit f7b2322

File tree

8 files changed

+43
-207
lines changed

8 files changed

+43
-207
lines changed

HISTORY.md

Lines changed: 1 addition & 207 deletions
Original file line numberDiff line numberDiff line change
@@ -1,207 +1 @@
1-
# History
2-
----
3-
4-
## 10.3.0 / 2020-05-08
5-
6-
- Adjust trigger order of `onChange` & `onSelect`
7-
8-
## 9.2.0 / 2019-07-16
9-
10-
- Adjust trigger order of `onChange` & `onSelect`
11-
12-
## 9.0.0 / 2019-02-27
13-
14-
- Multiple mode also support `showArrow`
15-
- Add loading className
16-
17-
## 8.8.0 / 2019-01-29
18-
19-
- Add an additional className when popup is empty
20-
21-
## 8.6.0 / 2018-11-27
22-
23-
- Added `loading` prop.
24-
- Allow search Option Group title.
25-
26-
## 8.5.0 / 2018-11-26
27-
28-
- Added `dropdownRender` prop.
29-
30-
## 8.4.0 / 2018-10-08
31-
32-
- Adjust focus / blur logic
33-
- Space support open select
34-
35-
## 8.3.0 / 2018-09-28
36-
37-
- `open` support controlled
38-
39-
## 8.2.0 / 2018-08-07
40-
41-
- Add inputIcon, clearIcon, removeIcon.
42-
43-
## 8.1.0 / 2018-06-24
44-
45-
- Add id prop.
46-
- Support data attributes. https://github.com/react-component/select/pull/305
47-
48-
## 8.0.2 / 2018-05-03
49-
50-
- Refactoring: Migrate to new lifecycle methods https://github.com/react-component/select/pull/291
51-
52-
## 8.0.0 / 2018-04-28
53-
54-
- Upgrade rc-menu to 7.0.1
55-
- Add prop `autoClearSearchValue`.
56-
57-
## 7.7.8 / 2018-04-19
58-
59-
- Fix: value is wrong when blur https://github.com/react-component/select/pull/290
60-
61-
## 7.7.6 / 2018-03-30
62-
63-
- Refactoring: update state.value format https://github.com/react-component/select/pull/277
64-
65-
## 7.7.5 / 2018-03-13
66-
67-
- Fire change on blur for tags mode https://github.com/react-component/select/pull/271
68-
- Fix defaultFilter can not filter array children https://github.com/react-component/select/pull/276
69-
70-
## 7.5.0 / 2017-12-11
71-
72-
- Add onInputKeydown
73-
74-
## 7.2.0 / 2017-11-16
75-
76-
- Add onPopupScroll.
77-
78-
## 7.0.0 / 2017-10-30
79-
80-
- Allow numbe value in Option
81-
- Add maxTagCount and maxTagTextLength https://github.com/react-component/select/pull/224
82-
- Add showAction https://github.com/react-component/select/pull/224
83-
- Add onMouseEnter and onMouseLeave https://github.com/react-component/select/pull/238
84-
- Add focus() and autoFocus
85-
86-
## 6.9.0 / 2017-09-01
87-
88-
- add backfill in single/combobox mode
89-
90-
## 6.8.0 / 2017-03-24
91-
92-
- support allowClear in multiple/tags mode
93-
94-
## 6.7.0 / 2017-01-03
95-
96-
- support getInputElement https://github.com/react-component/select/pull/145
97-
98-
## 6.6.0 / 2016-11-01
99-
100-
- add tokenSeparators for multiple and tag mode
101-
102-
## 6.4.0 / 2016-05-26
103-
104-
- auto expand input in ie10/11 https://github.com/react-component/select/pull/93
105-
- realign when value change. https://github.com/react-component/select/pull/92
106-
107-
## 6.3.0 / 2016-04-28
108-
109-
- support onBlur
110-
111-
## 6.2.0 / 2016-04-20
112-
113-
- remove searchPlaceholder
114-
115-
## 6.1.0 / 2016-04-18
116-
117-
- go with http://semantic-ui.com/modules/dropdown.html#search-selection
118-
119-
## 6.0.0 / 2016-03-16
120-
121-
- remove defaultLabel/label
122-
- add labelInValue prop to control label
123-
- support dropdownAlign
124-
125-
## 5.8.0 / 2016-01-11
126-
127-
- support value type to be number
128-
129-
## 5.7.0 / 2016-01-06
130-
131-
- add getPopupContainer prop
132-
133-
## 5.6.0 / 2016-01-01
134-
135-
- scroll to active item when open menu on single mode
136-
137-
## 5.5.0 / 2015-12-22
138-
139-
- add defaultActiveFirstOption prop
140-
141-
## 5.4.0 / 2015-12-01
142-
143-
- fix disabled for old ie
144-
145-
## 5.3.0 / 2015-11-30
146-
147-
- add choiceTransitionName prop
148-
149-
## 5.2.0 / 2015-11-24
150-
151-
- do not hide dropdown on multiple or tag mode
152-
153-
## 5.0.0 / 2015-10-22
154-
155-
- only support react 0.14+
156-
- auto adjust position if visible region is not enough
157-
158-
## 4.9.0 / 2015-09-10
159-
160-
- add label for onChange listener
161-
162-
## 4.8.0 / 2015-08-20
163-
164-
- make value a controlled value
165-
- add defaultValue prop
166-
- remove renderDropdownToBody prop. defaults to true
167-
168-
## 4.7.0 / 2015-08-18
169-
170-
implement searchPlaceholder to prevent bug for ie10
171-
172-
## 4.5.0 / 2015-07-30
173-
174-
use rc-animate & rc-align. (assets change)
175-
176-
## 4.4.0 / 2015-07-15
177-
178-
`new` support dropdownStyle dropdownMenuStyle prop
179-
180-
## 4.3.0 / 2015-07-14
181-
182-
`new` [#17](https://github.com/react-component/select/issues/17) support render dropdown to body
183-
184-
## 4.2.0 / 2015-07-07
185-
186-
`improved` [#15](https://github.com/react-component/select/issues/15) fix input in multiple mode
187-
188-
## 4.1.0 / 2015-07-01
189-
190-
`new` [#13](https://github.com/react-component/select/issues/13) add maxTagTextLength
191-
192-
## 4.0.0 / 2015-06-26
193-
194-
https://github.com/react-component/select/issues/11
195-
196-
## 3.5.0 / 2015-06-17
197-
198-
`new` [#6](https://github.com/react-component/select/issues/6) add OptGroup
199-
200-
201-
## 3.4.0 / 2015-06-15
202-
203-
`new` support showSearch/animation/transitionName/disabled props
204-
205-
## 3.1.0 / 2015-03-23
206-
207-
`new` [#2](https://github.com/react-component/select/pull/2) support tags config
1+
See https://github.com/react-component/select/releases

assets/index.less

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,16 @@
5353
opacity: 0.4;
5454
}
5555

56+
// ============== Search ===============
57+
.@{select-prefix}-selection-search-input {
58+
appearance: none;
59+
60+
&::-webkit-search-cancel-button {
61+
display: none;
62+
appearance: none;
63+
}
64+
}
65+
5666
// --------------- Single ----------------
5767
&-single {
5868
.@{select-prefix}-selector {

src/Selector/Input.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ const Input: React.RefForwardingComponent<InputRef, InputProps> = (
7373
disabled,
7474
tabIndex,
7575
autoComplete: autoComplete || 'off',
76+
type: 'search',
7677
autoFocus,
7778
className: `${prefixCls}-selection-search-input`,
7879
style: { ...style, opacity: editable ? null : 0 },

tests/Select.test.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -870,6 +870,16 @@ describe('Select.Basic', () => {
870870
expect(wrapper.find('.rc-select-item-empty').text()).toEqual('Not Found');
871871
});
872872

873+
it('search input type', () => {
874+
const wrapper = mount(
875+
<Select showSearch open>
876+
<Option value="1">1</Option>
877+
<Option value="2">2</Option>
878+
</Select>,
879+
);
880+
expect(wrapper.find('input').prop('type')).toBe('search');
881+
});
882+
873883
it('warns on invalid children', () => {
874884
const Foo = value => <div>foo{value}</div>;
875885
const errorSpy = jest.spyOn(console, 'error').mockImplementation(() => null);

tests/__snapshots__/Combobox.test.tsx.snap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ exports[`Select.Combobox renders correctly 1`] = `
2020
class="rc-select-selection-search-input"
2121
id="rc_select_TEST_OR_SSR"
2222
role="combobox"
23+
type="search"
2324
value=""
2425
/>
2526
</span>

tests/__snapshots__/Multiple.test.tsx.snap

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ exports[`Select.Multiple render not display maxTagPlaceholder if maxTagCount not
2323
readonly=""
2424
role="combobox"
2525
style="opacity: 0;"
26+
type="search"
2627
unselectable="on"
2728
value=""
2829
/>
@@ -116,6 +117,7 @@ exports[`Select.Multiple render truncates tags by maxTagCount and show maxTagPla
116117
readonly=""
117118
role="combobox"
118119
style="opacity: 0;"
120+
type="search"
119121
unselectable="on"
120122
value=""
121123
/>
@@ -206,6 +208,7 @@ exports[`Select.Multiple render truncates tags by maxTagCount and show maxTagPla
206208
readonly=""
207209
role="combobox"
208210
style="opacity: 0;"
211+
type="search"
209212
unselectable="on"
210213
value=""
211214
/>
@@ -285,6 +288,7 @@ exports[`Select.Multiple render truncates values by maxTagTextLength 1`] = `
285288
readonly=""
286289
role="combobox"
287290
style="opacity: 0;"
291+
type="search"
288292
unselectable="on"
289293
value=""
290294
/>

tests/__snapshots__/Select.test.tsx.snap

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ exports[`Select.Basic does not filter when filterOption value is false 1`] = `
2222
readonly=""
2323
role="combobox"
2424
style="opacity:0"
25+
type="search"
2526
unselectable="on"
2627
value=""
2728
/>
@@ -149,6 +150,7 @@ exports[`Select.Basic filterOption could be true as described in default value 1
149150
class="rc-select-selection-search-input"
150151
id="rc_select_TEST_OR_SSR"
151152
role="combobox"
153+
type="search"
152154
value="3"
153155
/>
154156
</span>
@@ -203,6 +205,7 @@ exports[`Select.Basic no search 1`] = `
203205
readonly=""
204206
role="combobox"
205207
style="opacity:0"
208+
type="search"
206209
unselectable="on"
207210
value=""
208211
/>
@@ -252,6 +255,7 @@ exports[`Select.Basic render renders aria-attributes correctly 1`] = `
252255
readonly=""
253256
role="combobox"
254257
style="opacity:0"
258+
type="search"
255259
unselectable="on"
256260
value=""
257261
/>
@@ -309,6 +313,7 @@ exports[`Select.Basic render renders correctly 1`] = `
309313
readonly=""
310314
role="combobox"
311315
style="opacity:0"
316+
type="search"
312317
unselectable="on"
313318
value=""
314319
/>
@@ -368,6 +373,7 @@ exports[`Select.Basic render renders data-attributes correctly 1`] = `
368373
readonly=""
369374
role="combobox"
370375
style="opacity:0"
376+
type="search"
371377
unselectable="on"
372378
value=""
373379
/>
@@ -427,6 +433,7 @@ exports[`Select.Basic render renders disabled select correctly 1`] = `
427433
readonly=""
428434
role="combobox"
429435
style="opacity:0"
436+
type="search"
430437
unselectable="on"
431438
value=""
432439
/>
@@ -471,6 +478,7 @@ exports[`Select.Basic render renders dropdown correctly 1`] = `
471478
autocomplete="off"
472479
class="antd-selection-search-input"
473480
role="combobox"
481+
type="search"
474482
value=""
475483
/>
476484
</span>
@@ -654,6 +662,7 @@ exports[`Select.Basic render renders role prop correctly 1`] = `
654662
readonly=""
655663
role="button"
656664
style="opacity:0"
665+
type="search"
657666
unselectable="on"
658667
value=""
659668
/>
@@ -712,6 +721,7 @@ exports[`Select.Basic should contain falsy children 1`] = `
712721
readonly=""
713722
role="combobox"
714723
style="opacity:0"
724+
type="search"
715725
unselectable="on"
716726
value=""
717727
/>
@@ -849,6 +859,7 @@ exports[`Select.Basic should render custom dropdown correctly 1`] = `
849859
readonly=""
850860
role="combobox"
851861
style="opacity: 0;"
862+
type="search"
852863
unselectable="on"
853864
value=""
854865
/>

0 commit comments

Comments
 (0)