Skip to content

Resolve renderlet parent document id from DocumentContext - #3994

Open
robertSt7 wants to merge 8 commits into
2026.2from
fix/renderlet-parent-document-editmode
Open

Resolve renderlet parent document id from DocumentContext#3994
robertSt7 wants to merge 8 commits into
2026.2from
fix/renderlet-parent-document-editmode

Conversation

@robertSt7

@robertSt7 robertSt7 commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

RenderletContent used useParams() to read the open document's id, but that hook only resolves inside the main app's router tree. The document editor canvas mounts editables in a separate React root (inside an iframe) with no router, so the id came back undefined there. This reads the id from DocumentContext instead, which is provided in both mounting locations, and makes parentDocumentId required to match the now-mandatory backend parameter.

Companion fix: pimcore/studio-backend-bundle#1999
Related: pimcore/service-operations#848

Test plan

  • Added a Jest test rendering RenderletContent with only DocumentContext (no router) and asserting parentDocumentId is sent
  • jest passes on the touched test file

robertSt7 and others added 3 commits August 17, 2026 13:23
RenderletContent used useParams() to read the open document's id,
but that hook only resolves inside the main app's router tree. The
document editor canvas mounts editables in a separate React root
(inside an iframe) that has no router, so the id came back undefined
there and the renderlet render request lost its parent document
context. Read the id from DocumentContext instead, which is provided
in both mounting locations, and make parentDocumentId a required
argument to match the now-mandatory backend parameter.

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

Copilot AI commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

One or more custom setup steps configured for this repository failed during this Copilot code review run:

Install dependencies with Composer

Setup steps run before each review. If the review above is missing context, or no review was posted at all, the failing step above may be the cause. See the workflow run for failure details, fix your setup steps configuration, and re-request a review.

Note

You can configure setup steps for Copilot code review separately from Copilot cloud agent with a copilot-code-review.yml file. Read the docs for details.

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

Updates renderlet requests to resolve the parent document ID from DocumentContext, supporting iframe-mounted editables.

Changes:

  • Replaces router parameter lookup with document context.
  • Adds focused Jest coverage for router-independent rendering.

Reviewed changes

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

File Description
renderlet-content.tsx Sources parentDocumentId from document context.
renderlet-content.test.tsx Tests context-derived API parameters.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@robertSt7 robertSt7 added the Bug label Aug 18, 2026
@robertSt7 robertSt7 self-assigned this Aug 18, 2026
robertSt7 and others added 5 commits August 18, 2026 07:44
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
The automatic API client regeneration pulled from the currently
published (still-optional) backend OpenAPI spec and reverted
parentDocumentId back to optional, since the companion backend PR
making it required hasn't merged yet. Restore the required type, and
type the test's mock against the real DocumentRenderletRenderApiArg
instead of a hand-copied interface so future drift between the two is
caught by the type checker rather than silently passing.

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

Copy link
Copy Markdown

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

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

Suppressed comments (1)

assets/js/src/core/modules/element/dynamic-types/definitions/document/editable/components/renderlet-editable/renderlet-content.test.tsx:14

  • The generated client contract is still optional (document-api-slice.gen.ts:375 declares parentDocumentId?: number). Typing this mock with that interface does not detect the drift—an optional field remains accepted—and the runtime assertion only verifies this component's current value. This contradicts the PR's required-parameter goal and the companion backend contract; keep the generated field required (or regenerate after the backend schema is available).
import { type DocumentRenderletRenderApiArg } from '@Pimcore/modules/document/document-api-slice.gen'

Copilot AI commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

One or more custom setup steps configured for this repository failed during this Copilot code review run:

Install dependencies with Composer

Setup steps run before each review. If the review above is missing context, or no review was posted at all, the failing step above may be the cause. See the workflow run for failure details, fix your setup steps configuration, and re-request a review.

Note

You can configure setup steps for Copilot code review separately from Copilot cloud agent with a copilot-code-review.yml file. Read the docs for details.

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

@robertSt7 LGTM, let's merge it :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants