Skip to content

fix(connection): restore connection handler mxGraph behavior#1025

Open
LOUISNOYEZ wants to merge 1 commit intomaxGraph:mainfrom
LOUISNOYEZ:fix/connection_handler_preview_restore_default_position
Open

fix(connection): restore connection handler mxGraph behavior#1025
LOUISNOYEZ wants to merge 1 commit intomaxGraph:mainfrom
LOUISNOYEZ:fix/connection_handler_preview_restore_default_position

Conversation

@LOUISNOYEZ
Copy link

@LOUISNOYEZ LOUISNOYEZ commented Mar 24, 2026

PR Checklist

  • Addresses an existing open issue: closes #<the_issue_number_here>. If not, explain why (minor changes, etc.).
  • You have discussed this issue with the maintainers of maxGraph, and you are assigned to the issue.
  • The scope of the PR is sufficiently narrow to be examined in a single session. A PR covering several issues must be split into separate PRs. Do not create a large PR, otherwise it cannot be reviewed and you will be asked to split it later or the PR will be closed.
  • I have added tests to prove my fix is effective or my feature works. This can be done in the form of automatic tests in packages/core/_tests_ or a new or altered Storybook story in packages/html/stories (an existing story may also demonstrate the change).
  • I have provided screenshot/videos to demonstrate the change. If no releavant, explain why.
  • I have added or edited necessary documentation, or no docs changes are needed.
  • The PR title follows the "Conventional Commits" guidelines.

Overview

Restore connection handler mxgraph behavior.
Delete preview edge entryX and entryY style properties when hovering a cell without without hovering a specific target connection point instead of setting them to 0. Currently, the connection preview entry position snaps to the top left corner of cell shapes, which is not intended behavior.

Bug description

Demonstration using the Anchor story

  • Current maxgraph behavior : The connection preview snaps to the top left of the cell shape.
connection_preview_wrong.mp4
  • Intended mxgraph behavior : The connection preview snaps to the bottom center of the cell shape.
connection_preview_right.mp4

Analysis

The behavior change was introduced in commit 648e324 where the connection handler file was changed from

if (constraint != null && constraint.point != null) {
this.edgeState.style.entryX = constraint.point.x;
this.edgeState.style.entryY = constraint.point.y;
} else {
delete this.edgeState.style.entryX;
delete this.edgeState.style.entryY;
}

to

if (constraint && constraint.point) {
this.edgeState.style.entryX = constraint.point.x;
this.edgeState.style.entryY = constraint.point.y;
} else {
this.edgeState.style.entryX = 0;
this.edgeState.style.entryY = 0;
}

Which remains to this day. Fixing the issue consists in reverting to the original code.

Notes

  • Although this pull request reverts to the initial mxgraph behavior, it provides no motivation for the initial behavior in the first place.
  • I've added no tests under packages/core/__tests__ as the issue is related to a transient rendering artefact. Correctness can be assed using any story involving the connection handler where its updateEdgeState method has not been overriden.

Keywords

closes #841

Summary by CodeRabbit

  • Bug Fixes
    • Improved edge rendering behavior by properly clearing edge styling properties instead of forcing them to zero values, resulting in more accurate connection appearance.

delete preview edge entryX and entryY style properties when hovering a cell without without hovering a specific target connection point.
@coderabbitai
Copy link

coderabbitai bot commented Mar 24, 2026

Walkthrough

The updateEdgeState method in ConnectionHandler now removes unused entryX and entryY style properties via deletion instead of forcing them to 0 when no constraint point is available, affecting edge connection preview styling.

Changes

Cohort / File(s) Summary
Edge Style Property Handling
packages/core/src/view/plugin/ConnectionHandler.ts
Modified updateEdgeState to delete entryX and entryY style properties instead of setting them to 0 when constraint point is unavailable. This prevents stale property values from affecting orthogonal edge preview rendering.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The PR title 'fix(connection): restore connection handler mxGraph behavior' directly addresses the main change: reverting a behavioral regression in the ConnectionHandler to restore original mxGraph behavior.
Linked Issues check ✅ Passed The PR fulfills the core requirement of issue #841: it restores the connection preview to match mxGraph behavior by deleting entryX/entryY properties instead of setting them to 0, resolving the mismatch between preview routing and final edge points.
Out of Scope Changes check ✅ Passed All changes are within scope: the modification only affects the updateEdgeState method in ConnectionHandler.ts to address the preview positioning issue, with no unrelated alterations.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description check ✅ Passed PR description is comprehensive and addresses all required template sections with clear details about the bug, analysis, and justification.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@LOUISNOYEZ LOUISNOYEZ marked this pull request as ready for review March 24, 2026 11:22
@sonarqubecloud
Copy link

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.

Orthogonal Story: the edge connection preview not always match the final edge points

1 participant