From 7b238c2711d3026d4a51b6dec19a015e08cb3781 Mon Sep 17 00:00:00 2001 From: Nikhil Tomar Date: Fri, 28 Jun 2024 14:35:12 +0530 Subject: [PATCH] fix: jaws to announce the status of max char/words usage --- packages/react/src/components/TextArea/TextArea.tsx | 7 ++++++- packages/react/src/internal/useAnnouncer.js | 3 +++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/react/src/components/TextArea/TextArea.tsx b/packages/react/src/components/TextArea/TextArea.tsx index 81236abd643b..0dc3c1f95676 100644 --- a/packages/react/src/components/TextArea/TextArea.tsx +++ b/packages/react/src/components/TextArea/TextArea.tsx @@ -459,7 +459,12 @@ const TextArea = React.forwardRef((props: TextAreaProps, forwardRef) => { )} {input} {normalizedSlug} - + {ariaAnnouncement} {isFluid &&
} diff --git a/packages/react/src/internal/useAnnouncer.js b/packages/react/src/internal/useAnnouncer.js index 94e787a4b6b5..24b3e00bdd45 100644 --- a/packages/react/src/internal/useAnnouncer.js +++ b/packages/react/src/internal/useAnnouncer.js @@ -7,6 +7,9 @@ export function useAnnouncer(textCount, maxCount, entityName = 'characters') { const lastTen = maxCount - 10; + if (textCount == maxCount) { + return `Maximum ${entityName} reached.`; + } if (textCount >= lastTen) { return `${maxCount - textCount} ${entityName} left.`; }