Skip to content

Conversation

@DymoneLewis
Copy link
Collaborator

@DymoneLewis DymoneLewis commented Nov 20, 2025

@changeset-bot
Copy link

changeset-bot bot commented Nov 20, 2025

⚠️ No Changeset found

Latest commit: 53439e0

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes various issues and problems reported during internal usage, focusing primarily on enhancing the overlap mode functionality for element stacking.

Key Changes

  • Extended overlap mode support: Added two new overlap modes (STATIC: -1, EDGE_TOP: 2) in addition to the existing DEFAULT (0) and INCREASE (1) modes, providing more flexible control over element layer ordering
  • Fixed selection-select bug: Corrected issue #2263 where multiple canvas clicks during box selection would incorrectly cache the stopMoveGraph setting
  • Improved node click detection: Enhanced touchpad click handling to prevent accidental drag events from blocking node selection when grid size is 1 or grid snapping is disabled

Reviewed Changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
packages/core/src/constant/index.ts Added STATIC (-1) and EDGE_TOP (2) enum values to OverlapMode
packages/core/src/model/GraphModel.ts Added setOverlapMode method and updated toFront logic to handle all four overlap modes; fixed spelling of "矩形" in comments
packages/core/src/model/node/BaseNodeModel.ts Added updateZIndexByOverlap method and event listener to dynamically update node zIndex when overlap mode changes
packages/core/src/model/edge/BaseEdgeModel.ts Added updateZIndexByOverlap method and event listener to dynamically update edge zIndex when overlap mode changes
packages/core/src/LogicFlow.tsx Exposed setOverlapMode method in public API
packages/core/src/view/node/BaseNode.tsx Fixed touchpad click detection logic to allow clicks when timeInterval < 100ms and not dragging
packages/extension/src/components/selection-select/index.ts Fixed bug where stopMoveGraph cache was incorrectly updated on multiple clicks; moved restoration logic earlier in drawOff
sites/docs/docs/api/model/graphModel.zh.md Updated documentation to describe all four overlap modes with detailed behavior explanations
sites/docs/docs/api/model/graphModel.en.md Updated English documentation for overlap modes
sites/docs/docs/api/detail/constructor.zh.md Updated constructor documentation with comprehensive overlapMode descriptions
sites/docs/docs/api/detail/constructor.en.md Updated English constructor documentation
sites/docs/examples/graph/basic/demo/graph.tsx Added demo buttons and logic to test overlap mode functionality
examples/feature-examples/src/pages/graph/index.tsx Added comprehensive overlap mode testing controls and demo logic
examples/feature-examples/src/pages/graph/nodes/centerAnchorRect.ts Added new custom node type with center-based anchors for testing

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +211 to +214
eventCenter.on('overlap:change', (data) => {
const { overlapMode: newMode } = data
this.updateZIndexByOverlap(newMode, this.zIndex || getZIndex())
})
Copy link

Copilot AI Nov 21, 2025

Choose a reason for hiding this comment

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

Event listener for 'overlap:change' is registered but never removed. This could potentially cause memory leaks when nodes are deleted, as the event listener will remain attached even after the node model is no longer in use. Consider adding cleanup logic (e.g., in a destroy/cleanup method) to remove this event listener using eventCenter.off('overlap:change', handler) when the node is deleted.

Copilot uses AI. Check for mistakes.
Comment on lines 157 to 160
eventCenter.on('overlap:change', (data) => {
const { overlapMode: newMode } = data
this.updateZIndexByOverlap(newMode, data.zIndex || getZIndex())
})
Copy link

Copilot AI Nov 21, 2025

Choose a reason for hiding this comment

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

Event listener for 'overlap:change' is registered but never removed. This could potentially cause memory leaks when edges are deleted, as the event listener will remain attached even after the edge model is no longer in use. Consider adding cleanup logic (e.g., in a destroy/cleanup method) to remove this event listener using eventCenter.off('overlap:change', handler) when the edge is deleted.

Copilot uses AI. Check for mistakes.
const lf = lfRef.current;
if (!lf) return;
lf.setOverlapMode(mode);
const order = lf.graphModel.sortElements.map((m) => (m as any).BaseType);
Copy link

Copilot AI Nov 21, 2025

Choose a reason for hiding this comment

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

Inconsistent approach to type checking between example files. This file uses (m as any).BaseType with a type cast, while examples/feature-examples/src/pages/graph/index.tsx uses the more type-safe m.modelType === ModelType.EDGE. Consider using modelType consistently across examples for better type safety and avoiding the need for type assertions.

Suggested change
const order = lf.graphModel.sortElements.map((m) => (m as any).BaseType);
const order = lf.graphModel.sortElements.map((m) => m.modelType);

Copilot uses AI. Check for mistakes.
const lf = lfRef.current;
if (!lf) return;
const order = lf.graphModel.sortElements.map((m) =>
(m as any).BaseType === 'edge' ? 'edge' : 'node',
Copy link

Copilot AI Nov 21, 2025

Choose a reason for hiding this comment

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

Inconsistent approach to type checking. Uses (m as any).BaseType with type cast instead of the type-safe m.modelType === ModelType.EDGE pattern used in the other example file. Consider using modelType consistently for better type safety.

Copilot uses AI. Check for mistakes.
@boyongjiong
Copy link
Collaborator

优秀~

@boyongjiong boyongjiong merged commit fe2aa11 into master Nov 21, 2025
1 check passed
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.

[Feature]: 设置overlapMode = 1,使edge在node上面,当选中node,edge被覆盖在下面,并且在node失去焦点后edge仍然被覆盖

3 participants