Skip to content

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

Open
LOUISNOYEZ wants to merge 3 commits intomaxGraph:mainfrom
LOUISNOYEZ:fix/connection_handler_preview_restore_default_position
Open

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

Conversation

@LOUISNOYEZ
Copy link
Copy Markdown

@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 preview rendering by removing stale connection coordinate styling when preview constraints are absent, producing more accurate connection visuals.
  • Documentation

    • Expanded and clarified connection-point docs: normalized entryX/entryY/exitX/exitY semantics (typical 0–1 range), how perimeter falls back to center, and how pixel offsets (entryDx/entryDy/exitDx/exitDy) apply after point computation.

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

coderabbitai bot commented Mar 24, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: ff303a62-d0af-4119-8a54-01af73191546

📥 Commits

Reviewing files that changed from the base of the PR and between c37947a and 8de4221.

📒 Files selected for processing (1)
  • packages/core/src/types.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/core/src/types.ts

Walkthrough

When no connection constraint.point exists, ConnectionHandler.updateEdgeState now deletes edgeState.style.entryX and edgeState.style.entryY instead of setting them to 0. JSDoc for CellStateStyle connection-point properties was expanded and clarified.

Changes

Cohort / File(s) Summary
Edge Style Property Handling
packages/core/src/view/plugin/ConnectionHandler.ts
In updateEdgeState, remove edgeState.style.entryX and edgeState.style.entryY via delete when no constraint.point is present, replacing prior assignments of 0.
Type / JSDoc Clarifications
packages/core/src/types.ts
Expanded and corrected JSDoc for CellStateStyle connection properties (entryX/entryY, exitX/exitY, entryDx/entryDy, exitDx/exitDy, entryPerimeter, exitPerimeter, perimeter), clarifying normalized coordinate semantics, offsets, and fallback behaviors.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

Suggested labels

enhancement

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title 'fix(connection): restore connection handler mxGraph behavior' clearly and concisely describes the main change, which is restoring mxGraph behavior in the connection handler.
Description check ✅ Passed The PR description is comprehensive and complete: includes a filled checklist, clear bug description with videos, analysis of the problematic change, and references issue #841. All essential information is provided.
Linked Issues check ✅ Passed The code changes directly address issue #841 by removing entryX/entryY property deletion and setting them to 0, restoring mxGraph behavior where the preview matches final edge points.
Out of Scope Changes check ✅ Passed All changes are in-scope: documentation updates clarify connection-point styling properties in types.ts, and ConnectionHandler.ts changes fix the preview behavior issue described in #841.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ 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
@tbouffard
Copy link
Copy Markdown
Member

ℹ️ I have been looking at the entryX/entryY properties. entryX is "The connection point in relative horizontal coordinates of an edge with its target terminal."
Setting entryX=0 and entryY=0, means that the constraint point is set to the point on the top left of the shape, which is what we previously saw.
When not setting entryX and entryY, no constraint point is used, and this is what we want to use here. See

const x = edge.style[source ? 'exitX' : 'entryX'];
if (x !== undefined) {
const y = edge.style[source ? 'exitY' : 'entryY'];
if (y !== undefined) {
point = new Point(x, y);
}
}

@sonarqubecloud
Copy link
Copy Markdown

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

3 participants