Skip to content

Commit

Permalink
fix(modal): x aria-labelledby closeText element (#277)
Browse files Browse the repository at this point in the history
Before, passing an element to the `closeText` prop would cause the modal's x
button's `aria-label` to be `[object Object]`. Now, the button is labelled by
the close button in the modal footer so that the screenreader reads out the same
text for both buttons.
  • Loading branch information
thallada authored Jun 11, 2018
1 parent d4ead91 commit b9e3586
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/Modal/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import Icon from '../Icon';
import newId from '../utils/newId';
import Variant from '../utils/constants';

const closeModalButtonId = 'paragonCloseModalButton';

class Modal extends React.Component {
constructor(props) {
super(props);
Expand Down Expand Up @@ -202,7 +204,7 @@ class Modal extends React.Component {
<Button
label={<Icon className={['fa', 'fa-times']} />}
className={['p-1']}
aria-label={this.props.closeText}
aria-labelledby={closeModalButtonId}
onClick={this.close}
inputRef={this.setFirstFocusableElement}
onKeyDown={this.handleKeyDown}
Expand All @@ -215,6 +217,7 @@ class Modal extends React.Component {
<div className={styles['modal-footer']}>
{this.renderButtons()}
<Button
id={closeModalButtonId}
label={this.props.closeText}
buttonType="secondary"
onClick={this.close}
Expand Down

0 comments on commit b9e3586

Please sign in to comment.