Skip to content

Commit

Permalink
fix: jaws to announce the status of max char/words usage
Browse files Browse the repository at this point in the history
  • Loading branch information
2nikhiltom committed Jun 28, 2024
1 parent 0574970 commit 7b238c2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/react/src/components/TextArea/TextArea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,12 @@ const TextArea = React.forwardRef((props: TextAreaProps, forwardRef) => {
)}
{input}
{normalizedSlug}
<span className={`${prefix}--text-area__counter-alert`} role="alert">
<span
className={`${prefix}--text-area__counter-alert`}
role="alert"
aria-atomic="true"
// aria-live="polite"
>
{ariaAnnouncement}
</span>
{isFluid && <hr className={`${prefix}--text-area__divider`} />}
Expand Down
3 changes: 3 additions & 0 deletions packages/react/src/internal/useAnnouncer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.`;
}
Expand Down

0 comments on commit 7b238c2

Please sign in to comment.