Fix: Remove leaked child change listener in HotgraphicModel (fixes #372) - #373
Merged
Merged
Conversation
joe-replin
approved these changes
Aug 11, 2026
There was a problem hiding this comment.
Pull request overview
Fixes the listener leak described in #372 by switching tooltip-sync item listeners from being attached directly to child models to being tracked by the parent HotgraphicModel, so they can be cleaned up via stopListening() when the component model is torn down.
Changes:
- Replace
child.on('change', ...)withthis.listenTo(child, 'change', ...)insideHotgraphicModel.setUpItems()to ensure listener cleanup on teardown.
Suppressed comments (1)
js/hotgraphicModel.js:41
listenToensures cleanup on model teardown, butsetUpItems()can run multiple times on the sameHotgraphicModelinstance. As written, each call will add anotherchangelistener (now tracked onthis), so the child’schangelistener count can still grow during the model’s lifetime. Consider de-duping by storing the per-child handler andstopListening(child, 'change', prevHandler)before binding a new one.
this.listenTo(child, 'change', () => {
tooltipModel.set({
...child.toJSON(),
...tooltip,
_classes: tooltipModel.get('_classes')
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
lemmyadams
approved these changes
Aug 11, 2026
|
🎉 This PR is included in version 6.21.1 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
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.
fixes #372
Fix
child.on('change', ...)withthis.listenTo(child, 'change', ...)inHotgraphicModel.setUpItems()so the listener is tracked against the component model and automatically removed viastopListening()when the model is torn down, instead of leaking on the child item indefinitely.Testing
setUpItems()multiple times for the same items (e.g. switch language / reset course).changelistener is attached per item (no growth in event listener count on the child model).