From c1af3c7a713b6877a3f0cf54cd21fac922ec5907 Mon Sep 17 00:00:00 2001 From: Anveshreddy mekala Date: Wed, 2 Aug 2023 10:20:50 -0500 Subject: [PATCH] feat(text-area): provide additional context for AT users when character limit exceeds (#7412) **Related Issue:** #6630 ## Summary This PR will provide additional context for Assistive Technology users when character limit exceeds. After this change, AT users will receive error message as soon as the character limit is exceeded. --- .../src/components/text-area/resources.ts | 1 + .../src/components/text-area/text-area.scss | 4 ++ .../src/components/text-area/text-area.tsx | 63 +++++++++++-------- 3 files changed, 43 insertions(+), 25 deletions(-) diff --git a/packages/calcite-components/src/components/text-area/resources.ts b/packages/calcite-components/src/components/text-area/resources.ts index 4b6735649d5..684c692496b 100644 --- a/packages/calcite-components/src/components/text-area/resources.ts +++ b/packages/calcite-components/src/components/text-area/resources.ts @@ -1,4 +1,5 @@ export const CSS = { + assistiveText: "assistive-text", characterLimit: "character-limit", content: "content", container: "container", diff --git a/packages/calcite-components/src/components/text-area/text-area.scss b/packages/calcite-components/src/components/text-area/text-area.scss index a7c12ad62c4..281c15cfe57 100644 --- a/packages/calcite-components/src/components/text-area/text-area.scss +++ b/packages/calcite-components/src/components/text-area/text-area.scss @@ -177,6 +177,10 @@ textarea.block-size--full { @apply justify-end; } +.assistive-text { + @apply sr-only; +} + @include hidden-form-input(); @include disabled(); @include base-component(); diff --git a/packages/calcite-components/src/components/text-area/text-area.tsx b/packages/calcite-components/src/components/text-area/text-area.tsx index 89ee231c1bd..e432d3db50b 100644 --- a/packages/calcite-components/src/components/text-area/text-area.tsx +++ b/packages/calcite-components/src/components/text-area/text-area.tsx @@ -46,6 +46,7 @@ import { updateHostInteraction, } from "../../utils/interactive"; import { CharacterLengthObj } from "./interfaces"; +import { guid } from "../../utils/guid"; /** * @slot - A slot for adding text. @@ -260,12 +261,13 @@ export class TextArea return (