-
Notifications
You must be signed in to change notification settings - Fork 199
fix(VertexHandle): add missing setPosition call in processEvent #583
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
fix(VertexHandle): add missing setPosition call in processEvent #583
Conversation
Body of processEvent funciton inside VertexHandle was missing setPosition call that will properly update the values inside CellStyle This ensures the shape's internal lines are redrawn correctly during hnadle movements. Before this change, dragging the custom handles did not update the shape's divider positions due to the missing setPosition call.
WalkthroughThe changes in this pull request involve a modification to the Changes
Assessment against linked issues
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (1)
packages/core/src/view/cell/VertexHandle.ts (1)
132-133: Consider adding tests to prevent regression.Since this was a bug fix for handle movement behavior, it would be valuable to add tests that verify:
- The
setPositionis called during handle movement- The shape's internal lines update correctly
- The divider positions update properly during drag operations
Would you like me to help create test cases for these scenarios?
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (1)
packages/core/src/view/cell/VertexHandle.ts(1 hunks)
🔇 Additional comments (1)
packages/core/src/view/cell/VertexHandle.ts (1)
132-132: LGTM! This fixes the handle position update issue.
The addition of setPosition call correctly addresses the bug where handle movements weren't properly updating the shape's internal lines and divider positions.
Let's verify this fixes issue #481 by checking for similar patterns in the codebase:
✅ Verification successful
The setPosition call addition follows the correct pattern and fixes the issue
The verification confirms:
VertexHandleis the base class implementing thesetPositionmethod- The method is properly called within
processEventafter calculating the new point position - The pattern is consistent with how custom handles are processed in both
VertexHandlerandEdgeHandler
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Check for similar handle implementations to confirm the pattern
# Look for other vertex handle implementations that use setPosition
ast-grep --pattern 'class $_ extends VertexHandle {
$$$
setPosition($_, $_, $_) {
$$$
}
}'
# Look for other handle processEvent implementations
ast-grep --pattern 'processEvent($_) {
$$$
setPosition($_, $_, $_)
$$$
}'
Length of output: 184
Script:
#!/bin/bash
# Let's try a different approach to verify the pattern
# First, let's find all handle-related files
fd "Handle\.ts$" --type f
# Then, let's look for setPosition usage patterns in handle files
rg "setPosition\(" -A 3 --type ts
# Also check for processEvent implementations
rg "processEvent\(" -A 5 --type ts
# Look for the base VertexHandle class definition
rg "class VertexHandle" -A 10 --type ts
Length of output: 4069
| alpha2 | ||
| ) | ||
| ); | ||
| this.setPosition(this.state.getPaintBounds(), pt, me); |
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.
praise: Good catch. This seems to have been removed by mistake in a3102af.
This line existed prior this commit and in the original mxGraph code
tbouffard
left a comment
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.
LGTM, thanks for this contribution.
✔️ Tested locally
Body of processEvent funciton inside VertexHandle was missing setPosition call that will properly update the values inside CellStyle This ensures the shape's internal lines are redrawn correctly during hnadle movements.
Before this change, dragging the custom handles did not update the shape's divider positions due to the missing setPosition call.
PR Checklist
Handlesstory #481 .maxGraph, and you are assigned to the issue.packages/core/_tests_or a new or altered Storybook story inpackages/html/stories(an existing story may also demonstrate the change).I have added or edited necessary documentation,or no docs changes are needed.Overview
Main issue was missing setPosition function call that was missing from processChange event. This line was present inside mxGraph code, it probably got overlooked while migrating the code. Adding this line back caused the custom setPosition function written inside story to be triggered and position the label lines correctly.
After change:
inner-rectangle.mov
Notes
ℹ️ This change only reflects the inner rectangle issue,not rotating handle being misaligned, that was fixed in other PR.
Summary by CodeRabbit
New Features
Bug Fixes