Skip to content

fix(gantt): properly cleanup mouseup event and destroy component#596

Open
Ander1404 wants to merge 1 commit intofrappe:masterfrom
Ander1404:fixgantt
Open

fix(gantt): properly cleanup mouseup event and destroy component#596
Ander1404 wants to merge 1 commit intofrappe:masterfrom
Ander1404:fixgantt

Conversation

@Ander1404
Copy link
Copy Markdown

🐛 Problem

The Gantt component was attaching global listeners (document.addEventListener('mouseup')) using anonymous functions, making it impossible to remove them when the component was destroyed or re-created.

This caused:

  • Accumulation of listeners over time
  • Unpredictable behavior (drag getting stuck, events firing multiple times)
  • Memory leaks
  • Blank pages in some cases (SPA)

✅ Solution

  • Added a destroy() method to properly clean up:
  • Event listeners
  • DOM elements (container & SVG)
  • CSS classes
  • Refactored mouseup handling:
  • Used a referenced handler (this.on_mouse_up)
  • Explicit removal of the listener via removeEventListener
  • Centralized cleanup in cleanup_bar_events

🧪 Impact / Outcome

  • Correct lifecycle management of the Gantt component
  • Memory leaks fixed
  • Stable behavior during drag/resize
  • Component can now safely be reset or destroyed

🔍 Notes

  • No visual changes
  • No breaking changes
  • Internal improvement for stability and maintainability

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.

1 participant