Skip to content

Commit 3b4c0e6

Browse files
supergibbsTheSharpieOne
authored andcommitted
feat(aria): add closeAriaLabel (#525)
Add closeAriaLabel to Alert and ModalHeader to override default close value Closes #524
1 parent 683dbdb commit 3b4c0e6

2 files changed

Lines changed: 9 additions & 3 deletions

File tree

src/Alert.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ const propTypes = {
1212
children: PropTypes.node,
1313
className: PropTypes.string,
1414
closeClassName: PropTypes.string,
15+
closeAriaLabel: PropTypes.string,
1516
cssModule: PropTypes.object,
1617
color: PropTypes.string,
1718
isOpen: PropTypes.bool,
@@ -28,13 +29,15 @@ const defaultProps = {
2829
tag: 'div',
2930
transitionAppearTimeout: 150,
3031
transitionEnterTimeout: 150,
31-
transitionLeaveTimeout: 150
32+
transitionLeaveTimeout: 150,
33+
closeAriaLabel: 'Close'
3234
};
3335

3436
const Alert = (props) => {
3537
const {
3638
className,
3739
closeClassName,
40+
closeAriaLabel,
3841
cssModule,
3942
tag: Tag,
4043
color,
@@ -59,7 +62,7 @@ const Alert = (props) => {
5962
const alert = (
6063
<Tag {...attributes} className={classes} role="alert">
6164
{ toggle ?
62-
<button type="button" className={closeClasses} aria-label="Close" onClick={toggle}>
65+
<button type="button" className={closeClasses} aria-label={closeAriaLabel} onClick={toggle}>
6366
<span aria-hidden="true">&times;</span>
6467
</button>
6568
: null }

src/ModalHeader.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,13 @@ const propTypes = {
1010
className: PropTypes.string,
1111
cssModule: PropTypes.object,
1212
children: PropTypes.node,
13+
closeAriaLabel: PropTypes.string,
1314
};
1415

1516
const defaultProps = {
1617
tag: 'h4',
1718
wrapTag: 'div',
19+
closeAriaLabel: 'Close',
1820
};
1921

2022
const ModalHeader = (props) => {
@@ -26,6 +28,7 @@ const ModalHeader = (props) => {
2628
toggle,
2729
tag: Tag,
2830
wrapTag: WrapTag,
31+
closeAriaLabel,
2932
...attributes } = props;
3033

3134
const classes = mapToCssModules(classNames(
@@ -35,7 +38,7 @@ const ModalHeader = (props) => {
3538

3639
if (toggle) {
3740
closeButton = (
38-
<button type="button" onClick={toggle} className="close" aria-label="Close">
41+
<button type="button" onClick={toggle} className="close" aria-label={closeAriaLabel}>
3942
<span aria-hidden="true">{String.fromCharCode(215)}</span>
4043
</button>
4144
);

0 commit comments

Comments
 (0)