Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update EuiConfirmModal to check for the presence of confirm and cancel buttons before trying to focus them #555

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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