From 4b8fd769f503ba9e27b4ed1f285b52138ac3015d Mon Sep 17 00:00:00 2001 From: Andrew Tran Date: Wed, 13 Sep 2023 19:36:05 +0000 Subject: [PATCH 1/9] Update notification banner for screen reader experience --- packages/terra-alert/CHANGELOG.md | 3 ++ packages/terra-alert/src/Alert.jsx | 14 ++++-- .../jest/__snapshots__/Alert.test.jsx.snap | 48 +++++++++++++++++++ 3 files changed, 61 insertions(+), 4 deletions(-) diff --git a/packages/terra-alert/CHANGELOG.md b/packages/terra-alert/CHANGELOG.md index 77ae978e5d4..43938522f2d 100644 --- a/packages/terra-alert/CHANGELOG.md +++ b/packages/terra-alert/CHANGELOG.md @@ -2,6 +2,9 @@ ## Unreleased +* Added + * Added visually hidden commas between alert content. + ## 4.80.0 - (September 21, 2023) * Changed diff --git a/packages/terra-alert/src/Alert.jsx b/packages/terra-alert/src/Alert.jsx index 31575fe88af..38ca408cfd3 100644 --- a/packages/terra-alert/src/Alert.jsx +++ b/packages/terra-alert/src/Alert.jsx @@ -7,6 +7,7 @@ import { v4 as uuidv4 } from 'uuid'; import ResponsiveElement from 'terra-responsive-element'; import Button from 'terra-button'; +import VisuallyHiddenText from 'terra-visually-hidden-text'; import { IconAlert, IconError, @@ -188,10 +189,14 @@ const Alert = ({ 'actions-custom': type === AlertTypes.CUSTOM, }); actionsSection = ( -
- {action} - {dismissButton} -
+ <> + +
+ {action} + {action && dismissButton && } + {dismissButton} +
+ ); } @@ -205,6 +210,7 @@ const Alert = ({ {title || defaultTitle} )} + {children && } {children} ); diff --git a/packages/terra-alert/tests/jest/__snapshots__/Alert.test.jsx.snap b/packages/terra-alert/tests/jest/__snapshots__/Alert.test.jsx.snap index 7ba97c2fc2a..e62b1c6e5f5 100644 --- a/packages/terra-alert/tests/jest/__snapshots__/Alert.test.jsx.snap +++ b/packages/terra-alert/tests/jest/__snapshots__/Alert.test.jsx.snap @@ -29,6 +29,9 @@ exports[`Alert of type advisory with text content should render an Alert compone > Terra.alert.advisory + This is an advisory alert. @@ -74,6 +77,9 @@ exports[`Alert of type alert with text content should render an Alert component > Terra.alert.alert + This is a test @@ -119,6 +125,9 @@ exports[`Alert of type custom with custom title and text content should render a > Help! + This is a custom alert. @@ -164,6 +173,9 @@ exports[`Alert of type error with text content should render an Alert component > Terra.alert.error + This is an error. @@ -249,6 +261,9 @@ exports[`Alert of type info with text content should render an Alert component o > Terra.alert.info + This is an information alert. @@ -294,10 +309,16 @@ exports[`Alert of type success with an action button text content should render > Terra.alert.success + This is a success alert. +
@@ -354,6 +375,9 @@ exports[`Alert of type success with text content should render an Alert componen > Terra.alert.success + This is a success alert.
@@ -399,6 +423,9 @@ exports[`Alert of type unsatisfied should render an unsatisfied Alert 1`] = ` > Terra.alert.unsatisfied + This is an unsatisfied alert. @@ -444,6 +471,9 @@ exports[`Alert of type unverified should render an unverified Alert 1`] = ` > Terra.alert.unverified + This is an unverified alert. @@ -489,6 +519,9 @@ exports[`Alert of type warning with text content should render an Alert componen > Terra.alert.warning + This is an warning. @@ -897,10 +930,16 @@ exports[`Dismissable Alert of type custom with action button, custom title and t > Help! + This is a custom alert. +
@@ -915,6 +954,9 @@ exports[`Dismissable Alert of type custom with action button, custom title and t type="button" variant="emphasis" /> +
+
From 7ad53ee8dd2c9bb4ff63c246c45571f873f25c4a Mon Sep 17 00:00:00 2001 From: Andrew Tran Date: Wed, 13 Sep 2023 20:05:51 +0000 Subject: [PATCH 2/9] Update dependencies --- packages/terra-alert/package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/terra-alert/package.json b/packages/terra-alert/package.json index 19f16a5c26f..17fa625bd7d 100644 --- a/packages/terra-alert/package.json +++ b/packages/terra-alert/package.json @@ -33,6 +33,7 @@ "terra-icon": "^3.57.1", "terra-responsive-element": "^5.37.0", "terra-theme-context": "^1.0.0", + "terra-visually-hidden-text": "^2.36.0", "uuid": "3.4.0" }, "scripts": { From b870af2f4dd292bdf351115faf2bbe7d1f286c66 Mon Sep 17 00:00:00 2001 From: Andrew Tran Date: Fri, 15 Sep 2023 16:16:02 +0000 Subject: [PATCH 3/9] Update dismiss button aria description to include title --- packages/terra-alert/src/Alert.jsx | 18 +++++-- .../jest/__snapshots__/Alert.test.jsx.snap | 48 ------------------- .../__snapshots__/ButtonGroup.test.jsx.snap | 4 +- .../ButtonGroupButton.test.jsx.snap | 2 +- .../jest/__snapshots__/Field.test.jsx.snap | 4 +- .../__snapshots__/TextareaField.test.jsx.snap | 4 +- .../__snapshots__/SearchField.test.jsx.snap | 2 +- 7 files changed, 22 insertions(+), 60 deletions(-) diff --git a/packages/terra-alert/src/Alert.jsx b/packages/terra-alert/src/Alert.jsx index 38ca408cfd3..9b7121f4ce5 100644 --- a/packages/terra-alert/src/Alert.jsx +++ b/packages/terra-alert/src/Alert.jsx @@ -172,11 +172,21 @@ const Alert = ({ const dismissButtonAriaDescribedBy = (title || defaultTitle) ? alertTitleId : alertMessageId; + const dismissButtonAriaDescription = () => { + if (title && defaultTitle) { + return `${defaultTitle} ${title}`; + } + + return undefined; + }; + let dismissButton; if (onDismiss) { + const ariaDescription = dismissButtonAriaDescription(); dismissButton = (
); diff --git a/packages/terra-alert/tests/jest/__snapshots__/Alert.test.jsx.snap b/packages/terra-alert/tests/jest/__snapshots__/Alert.test.jsx.snap index e62b1c6e5f5..7ba97c2fc2a 100644 --- a/packages/terra-alert/tests/jest/__snapshots__/Alert.test.jsx.snap +++ b/packages/terra-alert/tests/jest/__snapshots__/Alert.test.jsx.snap @@ -29,9 +29,6 @@ exports[`Alert of type advisory with text content should render an Alert compone > Terra.alert.advisory - This is an advisory alert. @@ -77,9 +74,6 @@ exports[`Alert of type alert with text content should render an Alert component > Terra.alert.alert - This is a test @@ -125,9 +119,6 @@ exports[`Alert of type custom with custom title and text content should render a > Help! - This is a custom alert. @@ -173,9 +164,6 @@ exports[`Alert of type error with text content should render an Alert component > Terra.alert.error - This is an error. @@ -261,9 +249,6 @@ exports[`Alert of type info with text content should render an Alert component o > Terra.alert.info - This is an information alert. @@ -309,16 +294,10 @@ exports[`Alert of type success with an action button text content should render > Terra.alert.success - This is a success alert. -
@@ -375,9 +354,6 @@ exports[`Alert of type success with text content should render an Alert componen > Terra.alert.success - This is a success alert.
@@ -423,9 +399,6 @@ exports[`Alert of type unsatisfied should render an unsatisfied Alert 1`] = ` > Terra.alert.unsatisfied - This is an unsatisfied alert. @@ -471,9 +444,6 @@ exports[`Alert of type unverified should render an unverified Alert 1`] = ` > Terra.alert.unverified - This is an unverified alert. @@ -519,9 +489,6 @@ exports[`Alert of type warning with text content should render an Alert componen > Terra.alert.warning - This is an warning. @@ -930,16 +897,10 @@ exports[`Dismissable Alert of type custom with action button, custom title and t > Help! - This is a custom alert. -
@@ -954,9 +915,6 @@ exports[`Dismissable Alert of type custom with action button, custom title and t type="button" variant="emphasis" /> -
-
diff --git a/packages/terra-button-group/tests/jest/__snapshots__/ButtonGroup.test.jsx.snap b/packages/terra-button-group/tests/jest/__snapshots__/ButtonGroup.test.jsx.snap index 7799914ec19..f704d6dc195 100644 --- a/packages/terra-button-group/tests/jest/__snapshots__/ButtonGroup.test.jsx.snap +++ b/packages/terra-button-group/tests/jest/__snapshots__/ButtonGroup.test.jsx.snap @@ -47,7 +47,7 @@ exports[`correctly applies the theme context className 1`] = `
); diff --git a/packages/terra-button-group/tests/jest/__snapshots__/ButtonGroup.test.jsx.snap b/packages/terra-button-group/tests/jest/__snapshots__/ButtonGroup.test.jsx.snap index f704d6dc195..7799914ec19 100644 --- a/packages/terra-button-group/tests/jest/__snapshots__/ButtonGroup.test.jsx.snap +++ b/packages/terra-button-group/tests/jest/__snapshots__/ButtonGroup.test.jsx.snap @@ -47,7 +47,7 @@ exports[`correctly applies the theme context className 1`] = `