Skip to content

Commit

Permalink
fix: Textarea value.length undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
Brokyeom committed Nov 26, 2024
1 parent b3e4965 commit a15cfeb
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions packages/ui/Input/TextArea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const TextArea = forwardRef<HTMLTextAreaElement, TextAreaProps>((props, forwarde
isError,
validationFn,
errorMessage,
value = '',
value,
disableEnterSubmit = false,
maxLength,
fixedHeight,
Expand All @@ -45,8 +45,8 @@ const TextArea = forwardRef<HTMLTextAreaElement, TextAreaProps>((props, forwarde
const { onChange, ...restInputProps } = inputProps;
const { disabled, readOnly, required } = restInputProps;

const isValid = validationFn ? validationFn(value) : true;
const isEmpty = value.length === 0;
const isValid = validationFn ? validationFn(value ?? '') : true;
const isEmpty = value && value.length === 0;

const submitButtonRef = useRef<HTMLButtonElement | null>(null);

Expand Down Expand Up @@ -171,8 +171,8 @@ const TextArea = forwardRef<HTMLTextAreaElement, TextAreaProps>((props, forwarde
)}

{maxLength ? (
<p className={`${S.count} ${value.length > maxLength ? S.maxCount : ''}`}>
{value.length}/{maxLength}
<p className={`${S.count} ${!isEmpty && value && value.length > maxLength ? S.maxCount : ''}`}>
{value?.length}/{maxLength}
</p>
) : null}
</div>
Expand Down

0 comments on commit a15cfeb

Please sign in to comment.