Skip to content

Prevent unmounted EuiGlobalToastList from causing errors#1606

Merged
thompsongl merged 6 commits into
elastic:masterfrom
thompsongl:1595-toast
Feb 27, 2019
Merged

Prevent unmounted EuiGlobalToastList from causing errors#1606
thompsongl merged 6 commits into
elastic:masterfrom
thompsongl:1595-toast

Conversation

@thompsongl
Copy link
Copy Markdown
Contributor

@thompsongl thompsongl commented Feb 26, 2019

Summary

Fixes #1595, in which attempts to do calculations on a element that had become null caused errors.

  • Cancel requestAnimationFrame updates in componentWillUnmount
  • Prevent accessing properties on a nulled DOM element

Checklist

- [ ] This was checked in mobile
- [ ] This was checked in IE11
- [ ] This was checked in dark mode
- [ ] Any props added have proper autodocs
- [ ] Documentation examples were added

  • A changelog entry exists and is marked appropriately

- [ ] This was checked for breaking changes and labeled appropriately
- [ ] Jest tests were updated or added to match the most common scenarios
- [ ] This was checked against keyboard-only and screenreader scenarios
- [ ] This required updates to Framer X components

Comment thread src/components/toast/global_toast_list.js Outdated
Comment thread src/components/toast/global_toast_list.js Outdated
Comment thread src/components/toast/global_toast_list.js Outdated
Comment thread src/components/toast/global_toast_list.js Outdated
const scrollToBottom = () => {
// Although we cancel the requestAnimationFrame in componentWillUnmount,
// it's possible for this.listElement to become null in the meantime
if (!this.listElement) return;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This check should resolve #1595

Copy link
Copy Markdown

@andrew-goldstein andrew-goldstein left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, the addition of the early return appears to resolve #1595

LGTM (with optional suggestions)

@thompsongl thompsongl merged commit ff99bfc into elastic:master Feb 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants