Skip to content

[Document] Open in new window uses the current URL after a main domain change - #4253

Open
sholzer wants to merge 2 commits into
2026.3from
claude/issue-pm-1642-open-in-new-window-url
Open

sholzer wants to merge 2 commits into
2026.3from
claude/issue-pm-1642-open-in-new-window-url

Conversation

@sholzer

@sholzer sholzer commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Changes in this pull request

Resolves https://github.com/pimcore/product-management/issues/1642

After the main domain of a site is changed, "Open in new window" in the document tree context menu and in the document editor toolbar kept opening the old domain until Studio was reloaded.

Cause. useOpenInNewWindow fetched the document with documentGetById.initiate({ id }), so RTK Query answered from its cache, and the cached settingsData.url (built server-side from the main domain) was stale. The call also kept a cache subscription that was never released.

Fix. The hook fetches fresh with initiate({ id }, { forceRefetch: true, subscribe: false }), the pattern already used in use-upload-conflict-modal.tsx and telemetry-drain-loader.ts. Both menu entries use this hook. The fullPath fallback and the error handling are unchanged. Each "Open in new window" click now makes one document GET instead of being served from the cache.

For reviewers to weigh:

  • The forward-merge of 2026.3 into 2026.x conflicts on this line, because 2026.x already has { subscribe: false } there. Resolve it to { forceRefetch: true, subscribe: false }, otherwise the fix is lost on 2026.x.
  • Existing behaviour, not changed here: the error branch does not return early, so a failed refetch while RTK still holds earlier data can still open the old URL.

Additional info

Tests

  • use-open-in-new-window.test.tsx (new, 3 tests): the hook requests a fresh document without keeping a subscription, opens the current settingsData.url after it changed (with a mock that behaves like the RTK cache), and falls back to fullPath. The first two fail without the fix.

Verified

  • check-types, lint, npm test (1224 tests on 2026.3) and build-app pass.
  • In a browser against a demo instance, with this branch's build served and every write blocked: the first "Open in new window" from the tree sends one document GET and opens the original URL; a second one without reloading sends a new GET and opens the changed URL (served by an intercepted response); the editor toolbar entry does the same.

Not verified

  • The old behaviour was not reproduced in a browser with an unfixed build; the unit test's cache emulation covers it.
  • No unit test for the error path.

The build output is not part of this PR.

🤖 Generated with Claude Code

sholzer and others added 2 commits October 22, 2026 15:39
…in new window

The hook reused the cached documentGetById result, so settingsData.url kept
the old main domain after a site change until Studio was reloaded. It now
requests with forceRefetch and without a lingering cache subscription.

Co-Authored-By: Claude <noreply@anthropic.com>
… in the test

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

Copy link
Copy Markdown

@sholzer
sholzer requested a review from vin0401 October 23, 2026 13:53
@sholzer
sholzer marked this pull request as ready for review October 23, 2026 13:53
Copilot AI balanced review requested due to automatic review settings October 23, 2026 13:53
@sholzer sholzer added this to the 2026.3.4 milestone Oct 23, 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.

🟢 Approval recommended

The narrow shared-hook fix addresses stale-cache reuse, preserves existing interfaces, and includes targeted regression coverage with no unresolved blocking findings.

No open issues 🎉

What changed in this PR

Verdict: LGTM. This fixes stale document URLs after a site’s main domain changes, at the shared hook used by the document tree and editor toolbar.

Changes:

  • Forces a fresh document request without retaining a cache subscription (use-open-in-new-window.tsx:45–48). This addresses stale-cache reuse at the owning hook rather than patching individual callers.
  • Adds regression tests for request options, changed-domain URLs, and the existing fullPath fallback (use-open-in-new-window.test.tsx:85–127).

Compatibility and coverage: Both affected actions use the shared hook. No public signature or return shape changes. The tests target the hook directly and cover the reported regression.

Documentation and remaining risks: No documentation or changelog files changed; the PR description explains the additional request per click. Error handling remains unchanged and lacks a dedicated test. Tests and browser checks were reported by the author, not rerun here.

File Description
assets/​js/​src/​core/​modules/​document/​actions/​open-in-new-window/​use-open-in-new-window.tsx Fetches fresh document data without retaining a subscription.
assets/​js/​src/​core/​modules/​document/​actions/​open-in-new-window/​use-open-in-new-window.test.tsx Tests fresh fetching, changed URLs, and fallback behavior.

Review effort: Balanced

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