Repository navigation
fix(elementTools): fix the tools position when attached directly to element view - #3065
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR fixes the positioning of element tools when they are attached directly to element views instead of being rendered in the tools layer. The changes introduce logic to differentiate between overlay tools (rendered in paper coordinates) and relative tools (rendered in element coordinates).
- Introduces helper functions to determine tool positioning context and retrieve appropriate options
- Updates tool positioning calculations to handle both overlay and relative coordinate systems
- Modifies various tool types (HoverConnect, Control, Button, Boundary) to use the new positioning logic
Reviewed Changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| packages/joint-core/src/elementTools/HoverConnect.mjs | Updates track matrix calculation to handle relative positioning |
| packages/joint-core/src/dia/ToolsView.mjs | Adds layer detection methods for determining tool positioning context |
| packages/joint-core/src/dia/ToolView.mjs | Adds isOverlay method to detect if tool is rendered in overlay mode |
| packages/joint-core/src/cellTools/helpers.mjs | Introduces helper functions for tool options and view bounding box calculation |
| packages/joint-core/src/cellTools/HoverConnect.mjs | Adds absolute track matrix method for compatibility |
| packages/joint-core/src/cellTools/Control.mjs | Updates handle positioning and extras calculation for relative positioning |
| packages/joint-core/src/cellTools/Button.mjs | Modifies button positioning to handle relative coordinate systems |
| packages/joint-core/src/cellTools/Boundary.mjs | Updates boundary calculation for relative positioning |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
kumilingus
marked this pull request as ready for review
September 11, 2025 14:23
zbynekstara
approved these changes
Sep 12, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR fixes the positioning of element tools when they are attached directly to element views rather than being rendered in the tools layer. It introduces logic to distinguish between:
Background:
Setting
layer: nullon atoolsViewappends tools directly into the cell view. TheelementToolsAPI was added afterlinkToolsand thelayeroption, so the combination ofelementToolswithlayer: nullwas never properly tested. The key difference is that element views are transformed by position and angle (so tools inside them use the element’s coordinate system), whereas links have no transformation (they always use the graph coordinate system).Changes:
HoverConnect,Control,Button,Boundary) to use the new positioning systemDocumentation
We should update our docs with the following: