Skip to content

Commit

Permalink
fix(TextArea): Error state not correctly set when maxlength is exceeded
Browse files Browse the repository at this point in the history
  • Loading branch information
feclist committed Nov 15, 2024
1 parent c0242f4 commit dc639e3
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/core/src/components/TextArea/TextArea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ const TextArea = forwardRef(
const numRows = rows || DEFAULT_ROWS[size];
const helpTextId = helpText && `${id}-help-text`;
const allowExceedingMaxLengthTextId = allowExceedingMaxLength && `${id}-allow-exceeding-max-length`;
const isErrorState = error || (maxLength && value?.length > maxLength);


const ariaDescribedby = useMemo(
() => [helpTextId, allowExceedingMaxLengthTextId].filter(id => !!id).join(" ") || undefined,
[helpTextId, allowExceedingMaxLengthTextId]
);

const [characterCount, setCharacterCount] = useState(value?.length || 0);
const isErrorState = error || (typeof maxLength === "number" && characterCount > maxLength);

const handleOnChange = useCallback(
(event: React.ChangeEvent<HTMLTextAreaElement>) => {
Expand Down

0 comments on commit dc639e3

Please sign in to comment.