Skip to content

Comments

fix(dia.HighlighterView): prevent highlighting nodes outside cell view#2900

Merged
Geliogabalus merged 3 commits intoclientIO:masterfrom
kumilingus:fix-highlighter-view-on-removed-nodes
May 19, 2025
Merged

fix(dia.HighlighterView): prevent highlighting nodes outside cell view#2900
Geliogabalus merged 3 commits intoclientIO:masterfrom
kumilingus:fix-highlighter-view-on-removed-nodes

Conversation

@kumilingus
Copy link
Contributor

@kumilingus kumilingus commented Mar 10, 2025

Description

When a highlighter is used with an SVGElement as its NodeSelector, and that element is not part of the CellView, the node will not be highlighted. Instead, a cell:highlighter:invalid event is triggered—similar to what happens with a non-existent selector.

Motivation and Context

When a port is highlighted using an SVGElement selector and its attributes are updated, we need to make the highlighter invalid. This is because ports are re-rendered on each update, and the original SVGElement is removed from the DOM. The problem manifest during link reconnection, when the use set port attributes on link:connect event.

Note: This issue does not occur when using a JSON-based selector.

@kumilingus kumilingus requested a review from Copilot April 29, 2025 11:41
Copy link

Copilot AI left a 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 improves the HighlighterView behavior by ensuring that highlighting only applies to nodes within the cell view.

  • Updated tests verify that nodes outside the DOM are not highlighted.
  • Modified the HighlighterView implementation to include a check using cellView.el.contains.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
packages/joint-core/test/jointjs/dia/HighlighterView.js Adjusted test assertions to confirm the update behavior when nodes are detached from the DOM and the handling of the dirty flag.
packages/joint-core/src/dia/HighlighterView.mjs Added a condition to ensure that a node is only highlighted if it is a valid SVGElement within the cell view.

@kumilingus kumilingus force-pushed the fix-highlighter-view-on-removed-nodes branch from 9342738 to 1203b58 Compare April 30, 2025 07:32
@kumilingus kumilingus requested a review from Geliogabalus April 30, 2025 08:11
@kumilingus kumilingus marked this pull request as ready for review May 19, 2025 08:58
@Geliogabalus Geliogabalus merged commit 6af4e41 into clientIO:master May 19, 2025
3 checks passed
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.

2 participants