-
Notifications
You must be signed in to change notification settings - Fork 199
fix(VertexHandler): fix top-left resize handle behavior #968
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
Conversation
The top-left resize handle (index 0) was triggering a move operation instead of a resize.
WalkthroughReplaced truthiness-based handle checks with explicit nullish checks in Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~5–10 minutes
Pre-merge checks and finishing touches✅ Passed checks (5 passed)
✨ Finishing touches🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
✅ Files skipped from review due to trivial changes (1)
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. 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.
Actionable comments posted: 0
🧹 Nitpick comments (1)
packages/core/src/view/handler/VertexHandler.ts (1)
634-642: Explicit null check correctly fixes handle index 0; consider aligning related checksChanging
if (handle)toif (handle !== null)is the right fix: it preserves the “no handle” sentinel while allowing index0(top‑left sizer) to start resizing and satisfies TypeScript’snumber | nullnarrowing into thestart(...)call.As a minor follow‑up, you might also consider updating the hover/connect‑highlight guard in
mouseMove:// current else if (!this.graph.isMouseDown && this.getHandleForEvent(me)) { me.consume(false); } // possible alignment else if (!this.graph.isMouseDown && this.getHandleForEvent(me) !== null) { me.consume(false); }so that the top‑left handle is treated consistently as a valid handle in all paths (including disabling connect highlight when hovering over it).
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
packages/core/src/view/handler/VertexHandler.ts(1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
packages/core/src/**/*.ts
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
packages/core/src/**/*.ts: Always include '.js' file extensions in import statements within packages/core/src/ to comply with the ESLint import plugin rule 'n/file-extension-in-import: ['error', 'always']'.
No console statements allowed in code (ESLint rule: 'no-console: error'). Use proper logging instead.
No eval() function calls allowed in code (ESLint rule: 'no-eval: error').
Const enums are forbidden. Convert to regular enums instead (ESLint enforcement).
Use single quotes in code formatting (Prettier config: 'singleQuote: true').
Maintain tab width of 2 spaces in code formatting (Prettier config: 'tabWidth: 2').
Keep lines to a maximum of 90 characters (Prettier config: 'printWidth: 90').
Use ES5 trailing commas in code formatting (Prettier config: 'trailingComma: es5').
Follow the existing code structure and patterns when modifying core source files in packages/core/src/.
Maintain strict TypeScript typing in all code modifications.
Use ESM (ECMAScript Module) format as the primary module system. CommonJS is generated as a secondary output via compilation.
Target ES2020 as the TypeScript compiler target for the core package.
Enable strict TypeScript mode including 'noImplicitOverride' and 'noImplicitReturns' in the core package configuration.
packages/core/src/**/*.ts: Use camelCase for naming in TypeScript files
Code must conform to ES2020 standard for browser compatibility
Target modern browsers (Chrome, Edge, Firefox, Safari, Chromium-based) with no IE support
Files:
packages/core/src/view/handler/VertexHandler.ts
packages/core/src/view/**/*.ts
📄 CodeRabbit inference engine (CLAUDE.md)
Wrap multiple model changes in batchUpdate() to ensure efficient updates
Files:
packages/core/src/view/handler/VertexHandler.ts
packages/*/src/**/*.ts
📄 CodeRabbit inference engine (CLAUDE.md)
packages/*/src/**/*.ts: Register shapes via registries (e.g., ShapeRegistry) before use in BaseGraph
Use BaseGraph with explicit feature registration for production use
Use Graph class for prototyping and evaluation where automatic default registration is needed
To minimize bundle size, use BaseGraph and import only required features
Files:
packages/core/src/view/handler/VertexHandler.ts
|
Hi and thanks for this PR. I will review the PR soon. |
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.
Thanks for this contribution and good catch.
This problem seems to have been introduced by mistake in 648e324.
Checking falsy number is a common regression introduced during the code simplification as part of the TypeScript migration. We already had to fix similar problems like in #592.
I took the liberty of pushing forward the use of the internal isNullish function to prepare for the future. This function also tests undefined values, and since we want to gradually remove or limit null values in the codebase, this is a step in the right direction.
I also took the opportunity to fix another falsy check issue instead of nullish.
|



The issue occurred because the condition if (handle) evaluated to false when the handle index was 0.
As a result, the top-left handle incorrectly initiated a move operation.
The condition has been updated from if (handle) to if (handle !== null) to correctly detect a non-null result.
Closes #944
Summary by CodeRabbit
Bug Fixes
Documentation
✏️ Tip: You can customize this high-level summary in your review settings.