Skip to content

Commit

Permalink
Update EuiConfirmModal to check for the presence of confirm and cance…
Browse files Browse the repository at this point in the history
…l buttons before trying to focus them.
  • Loading branch information
cjcenizal committed Mar 21, 2018
1 parent 4def580 commit c66dac7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

- Added initial sorting option to `EuiInMemoryTable` ([#547](https://github.com/elastic/eui/pull/547))

**Bug fixes**

- `EuiConfirmModal` will now check for the presence of confirm and cancel buttons before trying to focus them ([#555](https://github.com/elastic/eui/pull/555))

# [`0.0.32`](https://github.com/elastic/eui/tree/v0.0.32)

- Updated `EuiDescriptionList` to accept nodes for the titles and descriptions ([#552](https://github.com/elastic/eui/pull/552))
Expand Down
7 changes: 4 additions & 3 deletions src/components/modal/confirm_modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,12 @@ export class EuiConfirmModal extends Component {
// elements conflicts with the focus-trap logic we have on EuiModal.
const { defaultFocusedButton } = this.props;

// Wait a beat for the focus-trap to complete, and then set focus to the right button.
// Wait a beat for the focus-trap to complete, and then set focus to the right button. Check that
// the buttons exist first, because it's possible the modal has been closed already.
requestAnimationFrame(() => {
if (defaultFocusedButton === CANCEL_BUTTON) {
if (defaultFocusedButton === CANCEL_BUTTON && this.cancelButton) {
this.cancelButton.focus();
} else if (defaultFocusedButton === CONFIRM_BUTTON) {
} else if (defaultFocusedButton === CONFIRM_BUTTON && this.confirmButton) {
this.confirmButton.focus();
}
});
Expand Down

0 comments on commit c66dac7

Please sign in to comment.