@@ -186,23 +186,55 @@ const TextArea = React.forwardRef<TextAreaRef, TextAreaProps>(
186
186
val = fixEmojiLength ( val , maxLength ! ) ;
187
187
}
188
188
189
+ let suffixNode = suffix ;
190
+ let dataCount : ReactNode ;
191
+ if ( showCount ) {
192
+ const valueLength = [ ...val ] . length ;
193
+
194
+ if ( typeof showCount === 'object' ) {
195
+ dataCount = showCount . formatter ( {
196
+ value : val ,
197
+ count : valueLength ,
198
+ maxLength,
199
+ } ) ;
200
+ } else {
201
+ dataCount = `${ valueLength } ${ hasMaxLength ? ` / ${ maxLength } ` : '' } ` ;
202
+ }
203
+
204
+ suffixNode = (
205
+ < >
206
+ { suffixNode }
207
+ < span
208
+ className = { classNames ( `${ prefixCls } -data-count` , classes ?. count ) }
209
+ >
210
+ { dataCount }
211
+ </ span >
212
+ </ >
213
+ ) ;
214
+ }
215
+
189
216
const textarea = (
190
217
< BaseInput
191
218
value = { val }
192
219
allowClear = { allowClear }
193
220
handleReset = { handleReset }
194
- suffix = { suffix }
221
+ suffix = { suffixNode }
195
222
prefixCls = { prefixCls }
196
223
classes = { {
197
- affixWrapper : classNames (
198
- classes ?. affixWrapper ,
199
- allowClear ? `${ prefixCls } -textarea-allow-clear` : '' ,
200
- ) ,
224
+ affixWrapper : classNames ( classes ?. affixWrapper , {
225
+ [ ` ${ prefixCls } -show-count` ] : showCount ,
226
+ [ `${ prefixCls } -textarea-allow-clear` ] : allowClear ,
227
+ } ) ,
201
228
} }
202
229
disabled = { disabled }
203
230
focused = { focused }
204
231
style = { style }
205
232
inputStyle = { { resize : style ?. resize } }
233
+ dataAttrs = { {
234
+ affixWrapper : {
235
+ 'data-count' : typeof dataCount === 'string' ? dataCount : undefined ,
236
+ } ,
237
+ } }
206
238
inputElement = {
207
239
< ResizableTextArea
208
240
{ ...rest }
@@ -225,37 +257,6 @@ const TextArea = React.forwardRef<TextAreaRef, TextAreaProps>(
225
257
/>
226
258
) ;
227
259
228
- if ( showCount ) {
229
- const valueLength = [ ...val ] . length ;
230
-
231
- let dataCount : ReactNode ;
232
- if ( typeof showCount === 'object' ) {
233
- dataCount = showCount . formatter ( {
234
- value : val ,
235
- count : valueLength ,
236
- maxLength,
237
- } ) ;
238
- } else {
239
- dataCount = `${ valueLength } ${ hasMaxLength ? ` / ${ maxLength } ` : '' } ` ;
240
- }
241
-
242
- return (
243
- < div
244
- hidden = { rest . hidden }
245
- className = { classNames (
246
- `${ prefixCls } -show-count` ,
247
- className ,
248
- classes ?. countWrapper ,
249
- ) }
250
- style = { style }
251
- data-count = { dataCount }
252
- >
253
- { textarea }
254
- < span className = { `${ prefixCls } -data-count` } > { dataCount } </ span >
255
- </ div >
256
- ) ;
257
- }
258
-
259
260
return textarea ;
260
261
} ,
261
262
) ;
0 commit comments