Skip to content

Commit

Permalink
fix(TextField): when inputValue is undefined, length check fails (#2603)
Browse files Browse the repository at this point in the history
  • Loading branch information
YossiSaadi authored Nov 21, 2024
1 parent 00a9988 commit ad98340
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/core/src/components/TextField/TextField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ const TextField: VibeComponent<TextFieldProps, unknown> & {
}, [disabled, clearOnIconClick, onIconClick, currentStateIconName, controlled, onChangeCallback, clearValue]);

const validationClass = useMemo(() => {
if (typeof maxLength === "number" && inputValue.length > maxLength) {
if (typeof maxLength === "number" && inputValue && inputValue.length > maxLength) {
return FEEDBACK_CLASSES.error;
}

Expand All @@ -253,7 +253,7 @@ const TextField: VibeComponent<TextFieldProps, unknown> & {
}
const status = isRequiredAndEmpty ? "error" : validation.status;
return FEEDBACK_CLASSES[status];
}, [validation, isRequiredAndEmpty, inputValue]);
}, [maxLength, validation, isRequiredAndEmpty, inputValue]);

const hasIcon = iconName || secondaryIconName;
const shouldShowExtraText = showCharCount || (validation && validation.text) || isRequiredAndEmpty;
Expand Down

0 comments on commit ad98340

Please sign in to comment.