From ee6ee203a0c465683ec201f4a585a1105ff892df Mon Sep 17 00:00:00 2001 From: DAK <40970507+dakahn@users.noreply.github.com> Date: Fri, 29 Oct 2021 21:12:48 -0500 Subject: [PATCH 1/2] fix(Modal): add closeButtonLabel prop, add default value (#9998) Co-authored-by: Scott Strubberg Co-authored-by: Taylor Jones Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> --- .../__tests__/__snapshots__/PublicAPI-test.js.snap | 3 +++ packages/react/src/components/Modal/Modal.js | 9 +++++++-- .../__snapshots__/ModalWrapper-test.js.snap | 10 +++------- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/packages/react/__tests__/__snapshots__/PublicAPI-test.js.snap b/packages/react/__tests__/__snapshots__/PublicAPI-test.js.snap index d5682bce1b43..2f5f25f97d82 100644 --- a/packages/react/__tests__/__snapshots__/PublicAPI-test.js.snap +++ b/packages/react/__tests__/__snapshots__/PublicAPI-test.js.snap @@ -3829,6 +3829,9 @@ Map { "className": Object { "type": "string", }, + "closeButtonLabel": Object { + "type": "string", + }, "danger": Object { "type": "bool", }, diff --git a/packages/react/src/components/Modal/Modal.js b/packages/react/src/components/Modal/Modal.js index 66c61af0a479..0e29b0151e0d 100644 --- a/packages/react/src/components/Modal/Modal.js +++ b/packages/react/src/components/Modal/Modal.js @@ -49,6 +49,11 @@ export default class Modal extends Component { */ className: PropTypes.string, + /** + * Specify an label for the close button of the modal; defaults to close + */ + closeButtonLabel: PropTypes.string, + /** * Specify whether the Modal is for dangerous actions */ @@ -384,6 +389,7 @@ export default class Modal extends Component { shouldSubmitOnEnter, // eslint-disable-line size, hasScrollingContent, + closeButtonLabel, preventCloseOnClickOutside, // eslint-disable-line ...other } = this.props; @@ -420,11 +426,10 @@ export default class Modal extends Component { type="button" onClick={onRequestClose} title={ariaLabel ? ariaLabel : iconDescription} - aria-label={ariaLabel ? ariaLabel : iconDescription} + aria-label={closeButtonLabel ? closeButtonLabel : 'close'} ref={this.button}>