Skip to content
This repository has been archived by the owner on May 24, 2024. It is now read-only.

Commit

Permalink
Update dismiss button aria description to include title
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Tran authored and Andrew Tran committed Sep 15, 2023
1 parent affd6b7 commit e0f2705
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 60 deletions.
18 changes: 14 additions & 4 deletions packages/terra-alert/src/Alert.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -170,11 +170,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 = (
<Button
aria-describedby={dismissButtonAriaDescribedBy}
aria-describedby={ariaDescription ? undefined : dismissButtonAriaDescribedBy}
aria-description={ariaDescription}
text={intl.formatMessage({ id: 'Terra.alert.dismiss' })}
onClick={onDismiss}
/>
Expand All @@ -188,10 +198,10 @@ const Alert = ({
});
actionsSection = (
<>
<VisuallyHiddenText text="," />
{/* <VisuallyHiddenText text="," /> */}
<div className={actionsClassName}>
{action}
{action && dismissButton && <VisuallyHiddenText text="," />}
{/* {action && dismissButton && <VisuallyHiddenText text="," />} */}
{dismissButton}
</div>
</>
Expand All @@ -208,7 +218,7 @@ const Alert = ({
{title || defaultTitle}
</strong>
)}
{children && <VisuallyHiddenText text="," />}
{/* {children && <VisuallyHiddenText text="," />} */}
{children}
</div>
);
Expand Down
48 changes: 0 additions & 48 deletions packages/terra-alert/tests/jest/__snapshots__/Alert.test.jsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ exports[`Alert of type advisory with text content should render an Alert compone
>
Terra.alert.advisory
</strong>
<VisuallyHiddenText
text=","
/>
This is an advisory alert.
</div>
</div>
Expand Down Expand Up @@ -77,9 +74,6 @@ exports[`Alert of type alert with text content should render an Alert component
>
Terra.alert.alert
</strong>
<VisuallyHiddenText
text=","
/>
This is a test
</div>
</div>
Expand Down Expand Up @@ -125,9 +119,6 @@ exports[`Alert of type custom with custom title and text content should render a
>
Help!
</strong>
<VisuallyHiddenText
text=","
/>
This is a custom alert.
</div>
</div>
Expand Down Expand Up @@ -173,9 +164,6 @@ exports[`Alert of type error with text content should render an Alert component
>
Terra.alert.error
</strong>
<VisuallyHiddenText
text=","
/>
This is an error.
</div>
</div>
Expand Down Expand Up @@ -261,9 +249,6 @@ exports[`Alert of type info with text content should render an Alert component o
>
Terra.alert.info
</strong>
<VisuallyHiddenText
text=","
/>
This is an information alert.
</div>
</div>
Expand Down Expand Up @@ -309,16 +294,10 @@ exports[`Alert of type success with an action button text content should render
>
Terra.alert.success
</strong>
<VisuallyHiddenText
text=","
/>
This is a success alert.
</div>
</div>
</div>
<VisuallyHiddenText
text=","
/>
<div
className="actions"
>
Expand Down Expand Up @@ -375,9 +354,6 @@ exports[`Alert of type success with text content should render an Alert componen
>
Terra.alert.success
</strong>
<VisuallyHiddenText
text=","
/>
This is a success alert.
</div>
</div>
Expand Down Expand Up @@ -423,9 +399,6 @@ exports[`Alert of type unsatisfied should render an unsatisfied Alert 1`] = `
>
Terra.alert.unsatisfied
</strong>
<VisuallyHiddenText
text=","
/>
This is an unsatisfied alert.
</div>
</div>
Expand Down Expand Up @@ -471,9 +444,6 @@ exports[`Alert of type unverified should render an unverified Alert 1`] = `
>
Terra.alert.unverified
</strong>
<VisuallyHiddenText
text=","
/>
This is an unverified alert.
</div>
</div>
Expand Down Expand Up @@ -519,9 +489,6 @@ exports[`Alert of type warning with text content should render an Alert componen
>
Terra.alert.warning
</strong>
<VisuallyHiddenText
text=","
/>
This is an warning.
</div>
</div>
Expand Down Expand Up @@ -930,16 +897,10 @@ exports[`Dismissable Alert of type custom with action button, custom title and t
>
Help!
</strong>
<VisuallyHiddenText
text=","
/>
This is a custom alert.
</div>
</div>
</div>
<VisuallyHiddenText
text=","
/>
<div
className="actions actions-custom"
>
Expand All @@ -954,9 +915,6 @@ exports[`Dismissable Alert of type custom with action button, custom title and t
type="button"
variant="emphasis"
/>
<VisuallyHiddenText
text=","
/>
<Button
aria-describedby="alert-title-00000000-0000-0000-0000-000000000000"
isBlock={false}
Expand Down Expand Up @@ -1011,16 +969,10 @@ exports[`Dismissible Alert that includes actions section should render an alert
>
Terra.alert.alert
</strong>
<VisuallyHiddenText
text=","
/>
This is a test
</div>
</div>
</div>
<VisuallyHiddenText
text=","
/>
<div
className="actions"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ exports[`correctly applies the theme context className 1`] = `
<button
aria-disabled={false}
aria-pressed={false}
className="button neutral orion-fusion-theme button-group-button orion-fusion-theme"
className="button neutral button-group-button orion-fusion-theme"
data-terra-button-group-button={true}
disabled={false}
onBlur={[Function]}
Expand Down Expand Up @@ -100,7 +100,7 @@ exports[`correctly applies the theme context className 1`] = `
<button
aria-disabled={false}
aria-pressed={false}
className="button neutral orion-fusion-theme button-group-button orion-fusion-theme"
className="button neutral button-group-button orion-fusion-theme"
data-terra-button-group-button={true}
disabled={false}
onBlur={[Function]}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ exports[`correctly applies the theme context className 1`] = `
>
<button
aria-disabled={false}
className="button neutral orion-fusion-theme button-group-button orion-fusion-theme"
className="button neutral button-group-button orion-fusion-theme"
data-terra-button-group-button={true}
disabled={false}
onBlur={[Function]}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ exports[`correctly applies the theme context className 1`] = `
xmlns="http://www.w3.org/2000/svg"
>
<IconBase
className="IconError orion-fusion-theme"
className="IconError"
focusable="false"
height="1em"
isBidi={false}
Expand All @@ -84,7 +84,7 @@ exports[`correctly applies the theme context className 1`] = `
xmlns="http://www.w3.org/2000/svg"
>
<svg
className="tui-Icon icon IconError orion-fusion-theme"
className="tui-Icon icon IconError"
focusable="false"
height="1em"
role="presentation"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ exports[`correctly applies the theme context className 1`] = `
xmlns="http://www.w3.org/2000/svg"
>
<IconBase
className="IconError orion-fusion-theme"
className="IconError"
focusable="false"
height="1em"
isBidi={false}
Expand All @@ -82,7 +82,7 @@ exports[`correctly applies the theme context className 1`] = `
xmlns="http://www.w3.org/2000/svg"
>
<svg
className="tui-Icon icon IconError orion-fusion-theme"
className="tui-Icon icon IconError"
focusable="false"
height="1em"
role="presentation"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ exports[`Snapshots correctly applies the theme context className 1`] = `
<button
aria-disabled={false}
aria-label="Terra.searchField.submit-search"
className="button neutral compact orion-fusion-theme button"
className="button neutral compact button"
data-terra-search-field-button="Search"
disabled={false}
onBlur={[Function]}
Expand Down

0 comments on commit e0f2705

Please sign in to comment.