11import { clsx } from 'clsx' ;
2+ import { isReactRenderable } from '@rc-component/util' ;
23import type { ReactElement , ReactNode } from 'react' ;
34import React , { cloneElement , useRef } from 'react' ;
45import type { BaseInputProps } from './interface' ;
@@ -81,7 +82,8 @@ const BaseInput = React.forwardRef<HolderRef, BaseInputProps>((props, ref) => {
8182 ! ( typeof allowClear === 'object' && allowClear . disabled ) ;
8283 const clearIconCls = `${ prefixCls } -clear-icon` ;
8384 const iconNode =
84- typeof allowClear === 'object' && allowClear ?. clearIcon
85+ typeof allowClear === 'object' &&
86+ isReactRenderable ( allowClear ?. clearIcon )
8587 ? allowClear . clearIcon
8688 : '✖' ;
8789
@@ -99,7 +101,7 @@ const BaseInput = React.forwardRef<HolderRef, BaseInputProps>((props, ref) => {
99101 clearIconCls ,
100102 {
101103 [ `${ clearIconCls } -hidden` ] : ! needClear ,
102- [ `${ clearIconCls } -has-suffix` ] : ! ! suffix ,
104+ [ `${ clearIconCls } -has-suffix` ] : isReactRenderable ( suffix ) ,
103105 } ,
104106 classNames ?. clear ,
105107 ) }
@@ -119,14 +121,14 @@ const BaseInput = React.forwardRef<HolderRef, BaseInputProps>((props, ref) => {
119121 [ `${ affixWrapperPrefixCls } -focused` ] : focused , // Not used, but keep it
120122 [ `${ affixWrapperPrefixCls } -readonly` ] : readOnly ,
121123 [ `${ affixWrapperPrefixCls } -input-with-clear-btn` ] :
122- suffix && allowClear && value ,
124+ isReactRenderable ( suffix ) && allowClear && value ,
123125 } ,
124126 classes ?. affixWrapper ,
125127 classNames ?. affixWrapper ,
126128 classNames ?. variant ,
127129 ) ;
128130
129- const suffixNode = ( suffix || allowClear ) && (
131+ const suffixNode = ( isReactRenderable ( suffix ) || allowClear ) && (
130132 < span
131133 className = { clsx ( `${ prefixCls } -suffix` , classNames ?. suffix ) }
132134 style = { styles ?. suffix }
@@ -144,7 +146,7 @@ const BaseInput = React.forwardRef<HolderRef, BaseInputProps>((props, ref) => {
144146 { ...dataAttrs ?. affixWrapper }
145147 ref = { containerRef }
146148 >
147- { prefix && (
149+ { isReactRenderable ( prefix ) && (
148150 < span
149151 className = { clsx ( `${ prefixCls } -prefix` , classNames ?. prefix ) }
150152 style = { styles ?. prefix }
@@ -185,13 +187,13 @@ const BaseInput = React.forwardRef<HolderRef, BaseInputProps>((props, ref) => {
185187 element = (
186188 < GroupWrapperComponent className = { mergedGroupClassName } ref = { groupRef } >
187189 < WrapperComponent className = { mergedWrapperClassName } >
188- { addonBefore && (
190+ { isReactRenderable ( addonBefore ) && (
189191 < GroupAddonComponent className = { addonCls } >
190192 { addonBefore }
191193 </ GroupAddonComponent >
192194 ) }
193195 { element }
194- { addonAfter && (
196+ { isReactRenderable ( addonAfter ) && (
195197 < GroupAddonComponent className = { addonCls } >
196198 { addonAfter }
197199 </ GroupAddonComponent >
0 commit comments