Skip to content

Commit 95aca19

Browse files
d-reinholdpivotal
authored andcommitted
fix(alerts): JAWS indicates that alerts are alerts
[Finishes #101817262] Signed-off-by: Caroline Taymor <ctaymor@pivotal.io> Signed-off-by: Dominick Reinhold <dreinhold@pivotal.io>
1 parent 35bf4a1 commit 95aca19

File tree

2 files changed

+30
-6
lines changed

2 files changed

+30
-6
lines changed

spec/pivotal-ui-react/alerts/alerts_spec.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,10 @@ describe('SuccessAlert', function() {
8787
it('renders an icon in the alert', function() {
8888
expect('i').toHaveClass('fa-check-circle');
8989
});
90+
91+
it('has a "success alert" label', function() {
92+
expect('.alert .sr-only').toContainText('success alert message,');
93+
});
9094
});
9195
});
9296

@@ -104,6 +108,10 @@ describe('InfoAlert', function() {
104108
it('renders an icon in the alert', function() {
105109
expect('i').toHaveClass('fa-info-circle');
106110
});
111+
112+
it('has a "info alert" label', function() {
113+
expect('.alert .sr-only').toContainText('info alert message,');
114+
});
107115
});
108116
});
109117

@@ -121,6 +129,10 @@ describe('WarningAlert', function() {
121129
it('renders an icon in the alert', function() {
122130
expect('i').toHaveClass('fa-exclamation-triangle');
123131
});
132+
133+
it('has a "warning alert" label', function() {
134+
expect('.alert .sr-only').toContainText('warning alert message,');
135+
});
124136
});
125137
});
126138

@@ -138,5 +150,9 @@ describe('ErrorAlert', function() {
138150
it('renders an icon in the alert', function() {
139151
expect('i').toHaveClass('fa-exclamation-triangle');
140152
});
153+
154+
it('has an "error alert" label', function() {
155+
expect('.alert .sr-only').toContainText('error alert message,');
156+
});
141157
});
142158
});

src/pivotal-ui-react/alerts/alerts.js

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,15 @@ function defAlert(props) {
5454
withIcon: types.bool
5555
},
5656
render() {
57-
return <Alert {...props} {...this.props} />;
57+
const {children, ...others} = this.props;
58+
return (
59+
<Alert {...props} {...others}>
60+
<span className="sr-only">
61+
{(props.bsStyle === 'danger' ? 'error' : props.bsStyle) + ' alert message,'}
62+
</span>
63+
{children}
64+
</Alert>
65+
);
5866
}
5967
});
6068
}
@@ -179,13 +187,13 @@ var SuccessAlert = require('pui-react-alerts').SuccessAlert;
179187
180188
181189
```react_example_table
182-
<SuccessAlert>success</SuccessAlert>
190+
<SuccessAlert>Everything is wonderful</SuccessAlert>
183191
184-
<InfoAlert>info</InfoAlert>
192+
<InfoAlert>Here's some information for you</InfoAlert>
185193
186-
<WarningAlert>warning</WarningAlert>
194+
<WarningAlert>There is no parking on the dancefloor</WarningAlert>
187195
188-
<ErrorAlert>error</ErrorAlert>
196+
<ErrorAlert>Something has gone horribly awry</ErrorAlert>
189197
```
190198
*/
191199

@@ -199,7 +207,7 @@ parent: alerts_react
199207
Add the `dismissable` property to add a close button to the alert.
200208
201209
```react_example_table
202-
<SuccessAlert dismissable>success</SuccessAlert>
210+
<SuccessAlert dismissable>Everything is wonderful</SuccessAlert>
203211
```
204212
205213
If you want a callback to be called when the close button is

0 commit comments

Comments
 (0)