Skip to content

Commit ee6ee20

Browse files
dakahnsstrubbergtay1orjoneskodiakhq[bot]
committed
fix(Modal): add closeButtonLabel prop, add default value (#9998)
Co-authored-by: Scott Strubberg <sstrubberg@protonmail.com> Co-authored-by: Taylor Jones <tay1orjones@users.noreply.github.com> Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
1 parent f6352a1 commit ee6ee20

3 files changed

Lines changed: 13 additions & 9 deletions

File tree

packages/react/__tests__/__snapshots__/PublicAPI-test.js.snap

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3829,6 +3829,9 @@ Map {
38293829
"className": Object {
38303830
"type": "string",
38313831
},
3832+
"closeButtonLabel": Object {
3833+
"type": "string",
3834+
},
38323835
"danger": Object {
38333836
"type": "bool",
38343837
},

packages/react/src/components/Modal/Modal.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ export default class Modal extends Component {
4949
*/
5050
className: PropTypes.string,
5151

52+
/**
53+
* Specify an label for the close button of the modal; defaults to close
54+
*/
55+
closeButtonLabel: PropTypes.string,
56+
5257
/**
5358
* Specify whether the Modal is for dangerous actions
5459
*/
@@ -384,6 +389,7 @@ export default class Modal extends Component {
384389
shouldSubmitOnEnter, // eslint-disable-line
385390
size,
386391
hasScrollingContent,
392+
closeButtonLabel,
387393
preventCloseOnClickOutside, // eslint-disable-line
388394
...other
389395
} = this.props;
@@ -420,11 +426,10 @@ export default class Modal extends Component {
420426
type="button"
421427
onClick={onRequestClose}
422428
title={ariaLabel ? ariaLabel : iconDescription}
423-
aria-label={ariaLabel ? ariaLabel : iconDescription}
429+
aria-label={closeButtonLabel ? closeButtonLabel : 'close'}
424430
ref={this.button}>
425431
<Close20
426432
aria-hidden="true"
427-
aria-label="close"
428433
tabIndex="-1"
429434
className={`${this.modalCloseButtonClass}__icon`}
430435
/>

packages/react/src/components/ModalWrapper/__snapshots__/ModalWrapper-test.js.snap

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -109,19 +109,18 @@ exports[`ModalWrapper should render 1`] = `
109109
Transactional Modal
110110
</h3>
111111
<button
112+
aria-label="close"
112113
className="bx--modal-close"
113114
onClick={[Function]}
114115
type="button"
115116
>
116117
<ForwardRef(Close20)
117118
aria-hidden="true"
118-
aria-label="close"
119119
className="bx--modal-close__icon"
120120
tabIndex="-1"
121121
>
122122
<Icon
123123
aria-hidden="true"
124-
aria-label="close"
125124
className="bx--modal-close__icon"
126125
fill="currentColor"
127126
height={20}
@@ -132,15 +131,12 @@ exports[`ModalWrapper should render 1`] = `
132131
xmlns="http://www.w3.org/2000/svg"
133132
>
134133
<svg
135-
aria-hidden="true"
136-
aria-label="close"
134+
aria-hidden={true}
137135
className="bx--modal-close__icon"
138136
fill="currentColor"
139-
focusable="true"
137+
focusable="false"
140138
height={20}
141139
preserveAspectRatio="xMidYMid meet"
142-
role="img"
143-
tabIndex="-1"
144140
viewBox="0 0 32 32"
145141
width={20}
146142
xmlns="http://www.w3.org/2000/svg"

0 commit comments

Comments
 (0)