@@ -18,6 +18,14 @@ interface InputProps {
1818 onChange : React . ChangeEventHandler < HTMLInputElement | HTMLTextAreaElement | HTMLElement > ;
1919}
2020
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+
2129const Input : React . RefForwardingComponent < InputRef , InputProps > = (
2230 {
2331 prefixCls,
@@ -35,19 +43,27 @@ const Input: React.RefForwardingComponent<InputRef, InputProps> = (
3543 } ,
3644 ref ,
3745) => {
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 ;
3952
40- const { onKeyDown : onOriginKeyDown , onChange : onOriginChange } = inputNode . props ;
53+ function inputRef ( node : InputRef ) {
54+ fillRef ( node , ref ) ;
55+ fillRef ( node , originRef ) ;
56+ }
4157
4258 inputNode = React . cloneElement ( inputNode , {
4359 id,
44- ref,
60+ ref : inputRef ,
4561 disabled,
4662 tabIndex,
4763 autoComplete : 'off' ,
4864 autoFocus,
4965 className : `${ prefixCls } -selection-search-input` ,
50- style : { opacity : editable ? null : 0 } ,
66+ style : { ... style , opacity : editable ? null : 0 } ,
5167 role : 'combobox' ,
5268 'aria-expanded' : open ,
5369 'aria-haspopup' : 'listbox' ,
0 commit comments