Skip to content

fix(elementTools): fix the tools position when attached directly to element view - #3065

Merged
kumilingus merged 13 commits into
clientIO:masterfrom
kumilingus:element-tools-no-layer
Sep 16, 2025
Merged

kumilingus merged 13 commits into
clientIO:masterfrom
kumilingus:element-tools-no-layer

Conversation

@kumilingus

@kumilingus kumilingus commented Sep 11, 2025 •

Copy link
Copy Markdown
Contributor

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:

  • Overlay tools - rendered in paper (graph) coordinates
  • Relative tools - rendered in element coordinates

Background:

Setting layer: null on a toolsView appends tools directly into the cell view. The elementTools API was added after linkTools and the layer option, so the combination of elementTools with layer: null was 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:

  • Added helper functions to determine the tool positioning context and resolve the correct options
  • Updated tool positioning logic to handle both overlay and relative coordinate systems
  • Updated several tool types (HoverConnect, Control, Button, Boundary) to use the new positioning system

Documentation

We should update our docs with the following:

Assigning layer: null will implicitly set the element tools useModelGeometry and rotate options to true.

@kumilingus
kumilingus requested a review from Copilot September 11, 2025 14:01

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 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.

Comment thread packages/joint-core/src/cellTools/Control.mjs Outdated
@kumilingus
kumilingus marked this pull request as ready for review September 11, 2025 14:23
@kumilingus
kumilingus merged commit 354e75a into clientIO:master Sep 16, 2025
3 checks passed
@kumilingus
kumilingus deleted the element-tools-no-layer branch September 16, 2025 10:59
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.

3 participants