-
Notifications
You must be signed in to change notification settings - Fork 814
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
Map block: Remove resize event listener when component is unmounted #18489
Map block: Remove resize event listener when component is unmounted #18489
Conversation
Caution: This PR has changes that must be merged to WordPress.com |
Scheduled Jetpack release: February 2, 2021. Thank you for the great PR description! When this PR is ready for review, please apply the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM - the map contact page seems to have disappeared from the starter page templates, but you can replicate the issue by adding a map block to a post, deleting it and then resizing window
r220776-wpcom |
If using the Map block in a custom block preview (for example as part of a pattern in the page layout picker in: Automattic/wp-calypso#49101), when the user switches their pattern selection and the Map block is unmounted, the
resize
listener continues to fire if the user resizes the window. This results in a TypeError in the console, because the DOM element for the Map component is no longer around:The fix is to add a
removeEventListener
call when the component is unmounted.Changes proposed in this Pull Request:
window.removeEventListener
call to remove the resize listener when the component is unmounted.Jetpack product discussion
Does this pull request change what data or activity we track or use?
No
Testing instructions:
Test for regressions:
Proposed changelog entry for your changes: