From b68ac84499bb7a8e08797f8b7a21b7e79fe8e31f Mon Sep 17 00:00:00 2001 From: Yossi Saadi Date: Wed, 20 Nov 2024 21:46:57 +0200 Subject: [PATCH] fix(TextField): when inputValue is undefined, check fails --- packages/core/src/components/TextField/TextField.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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;