File tree Expand file tree Collapse file tree 3 files changed +47
-3
lines changed
Expand file tree Collapse file tree 3 files changed +47
-3
lines changed Original file line number Diff line number Diff line change @@ -72,7 +72,10 @@ const BaseInput: FC<BaseInputProps> = (props) => {
7272 value,
7373 hidden,
7474 className :
75- classNames ( inputElement . props ?. className , className ) || undefined ,
75+ classNames (
76+ inputElement . props ?. className ,
77+ ! hasPrefixSuffix ( props ) && ! hasAddon ( props ) && className ,
78+ ) || null ,
7679 style : {
7780 ...inputElement . props ?. style ,
7881 ...inputStyle ,
@@ -148,10 +151,9 @@ const BaseInput: FC<BaseInputProps> = (props) => {
148151 < span className = { mergedGroupClassName } style = { style } hidden = { hidden } >
149152 < span className = { mergedWrapperClassName } >
150153 { addonBefore && < span className = { addonCls } > { addonBefore } </ span > }
151- { cloneElement ( inputElement , {
154+ { cloneElement ( element , {
152155 style : inputStyle ?? null ,
153156 hidden : null ,
154- value,
155157 } ) }
156158 { addonAfter && < span className = { addonCls } > { addonAfter } </ span > }
157159 </ span >
Original file line number Diff line number Diff line change @@ -203,4 +203,16 @@ describe('BaseInput', () => {
203203 container . querySelector ( 'input' ) ?. classList . contains ( 'test-base' ) ,
204204 ) . toBeFalsy ( ) ;
205205 } ) ;
206+
207+ it ( 'should correct render with prefix and addon' , ( ) => {
208+ const { container } = render (
209+ < BaseInput
210+ prefixCls = "rc-input"
211+ prefix = "prefix"
212+ addonBefore = "addon"
213+ inputElement = { < input /> }
214+ /> ,
215+ ) ;
216+ expect ( container ) . toMatchSnapshot ( ) ;
217+ } ) ;
206218} ) ;
Original file line number Diff line number Diff line change @@ -74,6 +74,36 @@ exports[`BaseInput prefix and suffix should render properly 1`] = `
7474</div >
7575` ;
7676
77+ exports [` BaseInput should correct render with prefix and addon 1` ] = `
78+ <div >
79+ <span
80+ class = " rc-input-group-wrapper"
81+ >
82+ <span
83+ class = " rc-input-wrapper rc-input-group"
84+ >
85+ <span
86+ class = " rc-input-group-addon"
87+ >
88+ addon
89+ </span >
90+ <span
91+ class = " rc-input-affix-wrapper"
92+ >
93+ <span
94+ class = " rc-input-prefix"
95+ >
96+ prefix
97+ </span >
98+ <input
99+ value = " "
100+ />
101+ </span >
102+ </span >
103+ </span >
104+ </div >
105+ ` ;
106+
77107exports [` BaseInput should render perfectly 1` ] = `
78108<div >
79109 <input
You can’t perform that action at this time.
0 commit comments