Skip to content

Commit

Permalink
fix(textinput): enable display of character count without max length
Browse files Browse the repository at this point in the history
If showCharacterCount is true, but not maxLength, the character count will be displayed alone (X vs
X/Y)

fix #295
  • Loading branch information
blakekrammes committed Sep 3, 2021
1 parent 4b1a4f0 commit 90844f3
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/components/TextInput/TextInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -269,15 +269,15 @@ const TextInput = ({
<Icon path={mdiClose} size="1em" />
</StyledIconContainer>
)}
{showCharacterCount && maxLength && (
{showCharacterCount && (
<StyledCharacterCount
ref={characterCountRef}
errorMessage={errorMessage}
isValid={isValid}
textIsTooLong={(internalValue as string).length > maxLength}
textIsTooLong={maxLength ? (internalValue as string).length > maxLength : false}
{...characterCountProps}
>
{(internalValue as string).length} / {maxLength}
{(internalValue as string).length} {maxLength !== undefined ? `/ ${maxLength}` : null}
</StyledCharacterCount>
)}
{isValid === false && errorMessage && (
Expand Down

0 comments on commit 90844f3

Please sign in to comment.