@@ -18,6 +18,14 @@ interface InputProps {
18
18
onChange : React . ChangeEventHandler < HTMLInputElement | HTMLTextAreaElement | HTMLElement > ;
19
19
}
20
20
21
+ function fillRef ( node : InputRef , ref : React . LegacyRef < InputRef > | React . Ref < InputRef > ) {
22
+ if ( typeof ref === 'function' ) {
23
+ ref ( node ) ;
24
+ } else if ( typeof ref === 'object' ) {
25
+ ( ref as any ) . current = node ;
26
+ }
27
+ }
28
+
21
29
const Input : React . RefForwardingComponent < InputRef , InputProps > = (
22
30
{
23
31
prefixCls,
@@ -35,19 +43,27 @@ const Input: React.RefForwardingComponent<InputRef, InputProps> = (
35
43
} ,
36
44
ref ,
37
45
) => {
38
- let inputNode : React . ReactElement = inputElement || < input /> ;
46
+ let inputNode : React . ComponentElement < any , any > = inputElement || < input /> ;
47
+
48
+ const {
49
+ ref : originRef ,
50
+ props : { onKeyDown : onOriginKeyDown , onChange : onOriginChange , style } ,
51
+ } = inputNode ;
39
52
40
- const { onKeyDown : onOriginKeyDown , onChange : onOriginChange } = inputNode . props ;
53
+ function inputRef ( node : InputRef ) {
54
+ fillRef ( node , ref ) ;
55
+ fillRef ( node , originRef ) ;
56
+ }
41
57
42
58
inputNode = React . cloneElement ( inputNode , {
43
59
id,
44
- ref,
60
+ ref : inputRef ,
45
61
disabled,
46
62
tabIndex,
47
63
autoComplete : 'off' ,
48
64
autoFocus,
49
65
className : `${ prefixCls } -selection-search-input` ,
50
- style : { opacity : editable ? null : 0 } ,
66
+ style : { ... style , opacity : editable ? null : 0 } ,
51
67
role : 'combobox' ,
52
68
'aria-expanded' : open ,
53
69
'aria-haspopup' : 'listbox' ,
0 commit comments