Skip to content

fix(map): clear modelId recursively on grouped duplicates#234

Merged
vuntz merged 6 commits into
devfrom
MON-181396-map-fix-grouped-duplicate
May 4, 2026
Merged

fix(map): clear modelId recursively on grouped duplicates#234
vuntz merged 6 commits into
devfrom
MON-181396-map-fix-grouped-duplicate

Conversation

@vuntz
Copy link
Copy Markdown
Member

@vuntz vuntz commented Feb 23, 2026

Description

When copying/pasting or duplicating grouped elements in the MAP editor, clicking save deletes the parent group.

Root cause: When a group is duplicated or copy-pasted, only the top-level cells get their modelId cleared. Children nested inside the group keep their original modelId. On save, both original and cloned children share the same modelId, causing the backend to overwrite the original element's parentId with the clone's group cell ID. The original group then has zero children and disappears.

Fix: Clear modelId recursively on all descendants in Graph.duplicateCells, and recurse into children in the pasteHere and duplicate actions in Actions.js.

Fixes MON-181396

Type of change

  • Patch fixing an issue (non-breaking change)
  • New functionality (non-breaking change)
  • Breaking change (patch or feature) that might cause side effects breaking part of the Software

Target serie

  • 24.04.x
  • 24.10.x
  • 25.10.x
  • master

How this pull request can be tested ?

  1. Open the MAP editor
  2. Create elements and group them
  3. Duplicate the group (Ctrl+D) and save — both groups should persist
  4. Copy (Ctrl+C) and paste (Ctrl+V) the group and save — both groups should persist
  5. Reload the map and verify both groups still exist

Summary by Aikido

Security Issues: 0 🔍 Quality Issues: 1 Resolved Issues: 0

🐛 Bugfixes

  • Cleared modelId recursively for duplicated and pasted grouped descendants.

🔧 Refactors

  • Reused centralized duplicate attribute clearing in Graph.duplicateCells and actions.
  • Replaced for loops with forEach in duplicate and paste helpers.

More info

When duplicating or copy-pasting grouped elements, only top-level
cells had their modelId cleared. Children nested inside the group
kept their original modelId, causing the backend to overwrite the
original element's parentId on save — deleting the parent group.

Clear modelId recursively on all descendants in Graph.duplicateCells,
and recurse into children in the pasteHere and duplicate actions.

MON-181396
@github-actions
Copy link
Copy Markdown

Logo
Checkmarx One – Scan Summary & Detailsa3900f0e-bfd3-4b5b-ab51-aad152435b67

Great job! No new security vulnerabilities introduced in this pull request

Copy link
Copy Markdown

@Yassir-BenBOUBKER Yassir-BenBOUBKER left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to be tested, i well see tomorrow

vuntz added 3 commits April 21, 2026 21:12
… duplicate attribute clearing

Move recursive modelId and container viewId clearing into
Graph.duplicateCells so all callers (duplicate action, drag-connect,
EditorUi) benefit. In pasteHere, separate the attribute clearing from
the positioning logic so children of groups are not incorrectly
repositioned with absolute offsets.

Rebuild minified files.

MON-181396
@vuntz vuntz marked this pull request as ready for review April 21, 2026 20:19
@vuntz vuntz requested a review from a team as a code owner April 21, 2026 20:19
@vuntz vuntz requested review from Med1233 and Thebarda April 21, 2026 20:19
Comment thread src/main/webapp/js/grapheditor/Actions.js
Comment thread src/main/webapp/js/grapheditor/Actions.js Outdated
Comment thread src/main/webapp/js/grapheditor/Actions.js Outdated
Comment thread src/main/webapp/js/grapheditor/Graph.js Outdated
Replace for loops with forEach in clearPastedAttributes,
clearDuplicateAttributes, and their call sites.

MON-181396
@vuntz vuntz merged commit 88a2c02 into dev May 4, 2026
4 checks passed
@vuntz vuntz deleted the MON-181396-map-fix-grouped-duplicate branch May 4, 2026 14:22
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.

4 participants