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

Prevent unmounted EuiGlobalToastList from causing errors #1606

Merged
merged 6 commits into from
Feb 27, 2019

Conversation

thompsongl
Copy link
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

@@ -40,6 +43,10 @@ export class EuiGlobalToastList extends Component {
this.isScrollingToBottom = true;

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;

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

@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