diff --git a/packages/core/src/components/TextField/TextField.tsx b/packages/core/src/components/TextField/TextField.tsx index e958e6f870..6cc32df788 100644 --- a/packages/core/src/components/TextField/TextField.tsx +++ b/packages/core/src/components/TextField/TextField.tsx @@ -244,7 +244,7 @@ const TextField: VibeComponent & { }, [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; } @@ -253,7 +253,7 @@ const TextField: VibeComponent & { } 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;