-
Notifications
You must be signed in to change notification settings - Fork 1.3k
修复一些issue和内部使用过程中反馈的问题 #2314
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
修复一些issue和内部使用过程中反馈的问题 #2314
Conversation
|
There was a problem hiding this 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
stopMoveGraphsetting - 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.
| eventCenter.on('overlap:change', (data) => { | ||
| const { overlapMode: newMode } = data | ||
| this.updateZIndexByOverlap(newMode, this.zIndex || getZIndex()) | ||
| }) |
Copilot
AI
Nov 21, 2025
There was a problem hiding this comment.
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.
| eventCenter.on('overlap:change', (data) => { | ||
| const { overlapMode: newMode } = data | ||
| this.updateZIndexByOverlap(newMode, data.zIndex || getZIndex()) | ||
| }) |
Copilot
AI
Nov 21, 2025
There was a problem hiding this comment.
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.
| const lf = lfRef.current; | ||
| if (!lf) return; | ||
| lf.setOverlapMode(mode); | ||
| const order = lf.graphModel.sortElements.map((m) => (m as any).BaseType); |
Copilot
AI
Nov 21, 2025
There was a problem hiding this comment.
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.
| const order = lf.graphModel.sortElements.map((m) => (m as any).BaseType); | |
| const order = lf.graphModel.sortElements.map((m) => m.modelType); |
| const lf = lfRef.current; | ||
| if (!lf) return; | ||
| const order = lf.graphModel.sortElements.map((m) => | ||
| (m as any).BaseType === 'edge' ? 'edge' : 'node', |
Copilot
AI
Nov 21, 2025
There was a problem hiding this comment.
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.
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
|
优秀~ |
fix #2019 #2063 #2263 #2181