Skip to content

[Documents] Existing Areablock editable data becomes disconnected after upgrading from Pimcore v12 to v2026.2 and saving a document - #3934

Draft
ValeriaMaltseva wants to merge 4 commits into
2025.4from
fix/areablock-key-renumbering-on-save
Draft

[Documents] Existing Areablock editable data becomes disconnected after upgrading from Pimcore v12 to v2026.2 and saving a document#3934
ValeriaMaltseva wants to merge 4 commits into
2025.4from
fix/areablock-key-renumbering-on-save

Conversation

@ValeriaMaltseva

Copy link
Copy Markdown
Contributor

Fixes pimcore/platform-version#248

Problem

The areablock editable derived its value from the rendered editmode DOM instead of the backend-provided indices. AbstractBlockManager.ensureAllElementKeys() silently assigned new sequential keys to every .pimcore_area_entry element whose key attribute was missing or unreadable (e.g. custom areabrick wrapper templates in projects upgraded from v12).

Saving such a document — without touching anything — renumbered the areablock indices (e.g. content:12content:9) while the child editables kept their stored names (content:12.*), permanently disconnecting them from their area entry. The data remains in documents_editables under the old names, so affected documents are recoverable once keys are remapped.

The classic v12 editmode never had this problem: it selected only entries that already carry a key (.pimcore_block_entry[data-name="…"][key]) and never invented keys. The BlockManager for the plain block editable in this codebase already follows that pattern — the areablock manager was the outlier.

Fix

  • transformValue() now uses the backend-provided indices as the source of truth and only falls back to the DOM read when no server value exists
  • AreablockManager.getElementSelector() now requires the key attribute (classic parity, same as BlockManager), and getAreablockValue() no longer invents keys via ensureAllElementKeys() — unmanaged entries are ignored instead of being renumbered

New keys are still only allocated by explicit user operations (addArea, pasteArea) via calculateNextKey().

Tests

Regression tests written first (TDD): before the fix, the transformValue test reproduced the reported corruption exactly (server keys [5, 2, 12] came back as [1, 2, 3]). Full jest suite passes (219/219), ESLint clean.

Forward-merge

Base is 2025.4 (oldest affected maintained line) → forward-merge 2025.4 → 2026.2 → 2026.x.

🤖 Generated with Claude Code

…g child editables

The areablock editable derived its value from the rendered editmode DOM and
silently assigned new sequential keys to every area entry whose key attribute
was missing. Saving such a document renumbered the areablock indices (e.g.
content:12 -> content:9) while the child editables kept their stored names
(content:12.*), permanently disconnecting them from their area entry.

- transformValue now uses the backend-provided indices as the source of truth
  and only falls back to the DOM when no server value exists
- AreablockManager now ignores area entries without a key attribute (classic
  editmode parity, same as BlockManager) instead of inventing keys for them

Fixes pimcore/platform-version#248

Co-Authored-By: Claude <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 24, 2026 11:45
@ValeriaMaltseva ValeriaMaltseva added this to the 2025.4.9 milestone Jul 24, 2026
@ValeriaMaltseva ValeriaMaltseva changed the title [Documents] Fix areablock keys being renumbered on save, disconnecting child editables [Documents] Existing Areablock editable data becomes disconnected after upgrading from Pimcore v12 to v2026.2 and saving a document Jul 24, 2026

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

Fixes areablock key corruption by prioritizing backend indices over incomplete editmode DOM markup.

Changes:

  • Uses server-provided areablock values when available.
  • Ignores unkeyed DOM entries instead of assigning keys.
  • Adds regression tests for value transformation and key handling.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
dynamic-type-document-editable-areablock.tsx Prioritizes backend values.
dynamic-type-document-editable-areablock.test.tsx Tests server and DOM value handling.
areablock-manager.ts Filters unkeyed entries.
areablock-manager.test.ts Tests key preservation and allocation.

@pimcore-deployments
pimcore-deployments marked this pull request as draft July 24, 2026 11:54
@pimcore-deployments

Copy link
Copy Markdown
Collaborator

🚫 CI & merge-readiness guardrail failed — this PR has been converted to draft.

A PR can only be merged when it has no conflicts with the base branch and all CI checks pass.

  • CI check not successful: studio-frontend-build / test (cancelled).
  • CI check not successful: studio-frontend-build / commit-build (cancelled).
  • CI check not successful: studio-frontend-build / build (cancelled).
  • CI check not successful: studio-frontend-build / commit-lint (cancelled).

When fixed, press Ready for review to re-run the checks.

@ValeriaMaltseva
ValeriaMaltseva marked this pull request as ready for review July 24, 2026 11:57
ValeriaMaltseva and others added 2 commits July 24, 2026 14:58
…not the DOM

Follow-up to the review on #3934: restricting queryElements() to keyed nodes
also changed every edit operation, not just the DOM fallback. On upgraded
markup without key attributes, add/paste/move/remove started from an empty DOM
read, could reuse an existing server key, and saved without the backend-provided
entries — disconnecting their children again.

- getCurrentValue() uses the store value (backend indices) as the source of
  truth for operation payloads and key allocation; the DOM is only a fallback
  and is used for element lookup / node positioning
- key allocation now considers both the value keys and the DOM keys, so a new
  entry can never collide with an existing server key
- add/paste/move/remove/toggle build the new value by applying the operation to
  the authoritative array (pure helpers in areablock-utils), instead of
  re-reading the rendered DOM; handlePostOperation is gone
- reload mode uses the same value math instead of a parallel DOM element list

Covers add/paste/move/remove/reload against unkeyed wrappers plus the pure
value helpers.

Co-Authored-By: Claude <noreply@anthropic.com>
@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
1 New Major Issues (required ≤ 0)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

@ValeriaMaltseva
ValeriaMaltseva marked this pull request as draft July 24, 2026 13:26
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