File tree 3 files changed +49
-9
lines changed
3 files changed +49
-9
lines changed Original file line number Diff line number Diff line change @@ -29,6 +29,13 @@ export default {
29
29
this . $emit ( 'search' , this . $refs . input . stateValue )
30
30
this . $refs . input . focus ( )
31
31
} ,
32
+ focus ( ) {
33
+ this . $refs . input . focus ( )
34
+ } ,
35
+
36
+ blur ( ) {
37
+ this . $refs . input . blur ( )
38
+ } ,
32
39
getButtonOrIcon ( ) {
33
40
const { prefixCls, size } = this
34
41
const enterButton = getComponentFromProp ( this , 'enterButton' )
@@ -45,7 +52,7 @@ export default {
45
52
} ,
46
53
} )
47
54
} else if ( enterButtonAsElement . tag === 'button' ) {
48
- return cloneElement ( enterButtonAsElement [ 0 ] , {
55
+ return cloneElement ( enterButtonAsElement , {
49
56
on : {
50
57
click : this . onSearch ,
51
58
} ,
@@ -93,14 +100,7 @@ export default {
93
100
{ ...inputProps }
94
101
class = { inputClassName }
95
102
ref = 'input'
96
- >
97
- { /* <Icon
98
- slot='suffix'
99
- class={`${prefixCls}-icon`}
100
- onClick={this.onSearch}
101
- type='search'
102
- /> */ }
103
- </ Input >
103
+ />
104
104
)
105
105
} ,
106
106
}
Original file line number Diff line number Diff line change
1
+ import { mount } from '@vue/test-utils'
2
+ import { asyncExpect } from '@/tests/utils'
3
+ import Search from '../Search'
4
+ import Button from '../../button'
5
+ import focusTest from '../../../tests/shared/focusTest'
6
+
7
+ describe ( 'Input.Search' , ( ) => {
8
+ focusTest ( Search )
9
+
10
+ it ( 'should support custom button' , async ( ) => {
11
+ const wrapper = mount ( {
12
+ render ( ) {
13
+ return < Search enterButton = { < button > ok</ button > } />
14
+ } ,
15
+ } , { sync : false } )
16
+ await asyncExpect ( ( ) => {
17
+ expect ( wrapper . html ( ) ) . toMatchSnapshot ( )
18
+ } )
19
+ } )
20
+
21
+ it ( 'should support custom Button' , async ( ) => {
22
+ const wrapper = mount ( {
23
+ render ( ) {
24
+ return < Search enterButton = { < Button > ok</ Button > } />
25
+ } ,
26
+ } , { sync : false } )
27
+ await asyncExpect ( ( ) => {
28
+ expect ( wrapper . html ( ) ) . toMatchSnapshot ( )
29
+ } )
30
+ } )
31
+ } )
Original file line number Diff line number Diff line change
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports [` Input.Search should support custom Button 1` ] = `
4
+ <span class = " ant-input-search ant-input-search-enter-button ant-input-affix-wrapper ant-input-search ant-input-search-enter-button" ><input type = " text" class = " ant-input ant-input-search ant-input-search-enter-button" ><span class = " ant-input-suffix" ><button type = " button" class = " ant-btn ant-btn-default ant-input-search-button" ><span >ok</span ></button >
5
+ </span >
6
+ </span >
7
+ `;
8
+
9
+ exports[`Input.Search should support custom button 1`] = `<span class = " ant-input-search ant-input-search-enter-button ant-input-affix-wrapper ant-input-search ant-input-search-enter-button" ><input type = " text" class = " ant-input ant-input-search ant-input-search-enter-button" ><span class = " ant-input-suffix" ><button class = " " >ok</button ></span ></span >`;
You can’t perform that action at this time.
0 commit comments