@@ -268,14 +268,12 @@ function BaseField({
268
268
269
269
const ariaDescribedBy = originalAriaDescribedBy ?? ( message ? messageId : null )
270
270
271
- /**
272
- * Renders the character count element.
273
- * If the characterCountPosition value is 'hidden', it returns null.
274
- */
271
+ const renderCharacterCountBelow = characterCountPosition === 'below' && characterCount !== null
272
+ const renderCharacterCountInline =
273
+ characterCountPosition === 'inline' && characterCount !== null
274
+
275
275
function renderCharacterCount ( ) {
276
- return characterCountPosition !== 'hidden' ? (
277
- < FieldCharacterCount tone = { characterCountTone } > { characterCount } </ FieldCharacterCount >
278
- ) : null
276
+ return < FieldCharacterCount tone = { characterCountTone } > { characterCount } </ FieldCharacterCount >
279
277
}
280
278
281
279
const childrenProps : ChildrenRenderProps = {
@@ -297,7 +295,7 @@ function BaseField({
297
295
setCharacterCountTone ( inputLength . tone )
298
296
} ,
299
297
// If the character count is inline, we pass it as a prop to the children element so it can be rendered inline
300
- characterCountElement : characterCountPosition === 'inline' ? renderCharacterCount ( ) : null ,
298
+ characterCountElement : renderCharacterCountInline ? renderCharacterCount ( ) : null ,
301
299
}
302
300
303
301
React . useEffect (
@@ -360,7 +358,7 @@ function BaseField({
360
358
{ endSlot && endSlotPosition === 'fullHeight' ? endSlot : null }
361
359
</ Box >
362
360
363
- { message || characterCount ? (
361
+ { message || renderCharacterCountBelow ? (
364
362
< Columns align = "right" space = "small" maxWidth = { maxWidth } >
365
363
{ message ? (
366
364
< Column width = "auto" >
0 commit comments