Skip to content

Conversation

@Geliogabalus
Copy link
Contributor

@Geliogabalus Geliogabalus commented Jan 29, 2026

Summary

  • Fixes an issue where removing an element during pointermove or pointerup event handlers would cause errors
  • When findViewByModel() returns null (because the model was removed), falls back to using the original view reference

Problem

When an element is removed from the graph during a pointer event handler (e.g., deleting an element after dragging), subsequent calls to view.pointermove() or view.pointerup() would fail because findViewByModel(view.model) returns undefined for removed models.

Solution

Added a fallback to use the original view reference when findViewByModel() returns falsy:

// Before
view = this.findViewByModel(view.model);

// After
view = this.findViewByModel(view.model) || view;

This change is applied to both pointermove and pointerup handlers in packages/joint-core/src/dia/Paper.mjs.

@Geliogabalus Geliogabalus changed the title fix(dia.Paper): fixed an error when the model was removed in mouseup event fix(dia.Paper): handle element removal during pointer events Jan 30, 2026
Comment on lines +3020 to +3022
const testElementRect = testElementView.el.querySelector('rect');

document.addEventListener('mousemove', () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be done instead?

simulate.mousedown({ el: testElementRect });
simulate.mousemove({ el: testElementRect });
testElement.remove();
simulate.mouseup({ el: testElementRect });

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked, and with this setup it never even goes into paper.pointerup function when event is triggered, so this is meaningless I think.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is important that at the start of the event chain, the view is in the dom as a part of the paper.

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