fix(ui): clean up window event listeners and ResizeObserver in destroy()#831
Merged
koala73 merged 1 commit intokoala73:mainfrom Mar 5, 2026
Merged
Conversation
|
@NewCoder3294 is attempting to deploy a commit to the Elie Team on Vercel. A member of the Team first needs to authorize it. |
Multiple components added window-level event listeners using anonymous callbacks, making them impossible to remove later. This caused memory leaks as listeners accumulated across component lifecycles. - CountryTimeline: store theme-changed handler, remove in destroy() - DeckGLMap: store theme-changed handler, remove in destroy() - Map: store theme-changed handler, promote ResizeObserver from local variable to class property, disconnect and remove both in destroy() Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
c5493db to
b530dc9
Compare
aldoyh
pushed a commit
to aldoyh/worldmonitor
that referenced
this pull request
Mar 6, 2026
…y() (koala73#831) Multiple components added window-level event listeners using anonymous callbacks, making them impossible to remove later. This caused memory leaks as listeners accumulated across component lifecycles. - CountryTimeline: store theme-changed handler, remove in destroy() - DeckGLMap: store theme-changed handler, remove in destroy() - Map: store theme-changed handler, promote ResizeObserver from local variable to class property, disconnect and remove both in destroy() Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Multiple components add window-level event listeners using anonymous callbacks, making them impossible to remove when
destroy()is called. This causes memory leaks as listeners accumulate across component mount/unmount cycles (e.g., when switching views or panels).The pattern fixed in each component:
addEventListener→ stored as a named class propertydestroy()now callsremoveEventListenerwith the same function referenceComponents fixed
theme-changedlistener was never removed indestroy(). Stored handler asthis.handleThemeChange, addedremoveEventListenercall indestroy().theme-changedlistener was never removed indestroy(). Same fix pattern.theme-changedlistener was never removed indestroy(). Same fix pattern.ResizeObserverwas created as a local variable insidesetupResizeObserver(), so it could never be disconnected. Promoted tothis.resizeObserverclass property and addeddisconnect()call indestroy().Note:
BreakingNewsBanner.tswas also audited but already correctly stores all handler references and removes them in itsdestroy()method — no changes needed.Test plan
tsc --noEmit— confirmed passing in CI pre-push hook)theme-changedlisteners via DevTools Event Listeners panel🤖 Generated with Claude Code