Repository navigation
Conversation
…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>
|
There was a problem hiding this comment.
🟢 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
fullPathfallback (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



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.
useOpenInNewWindowfetched the document withdocumentGetById.initiate({ id }), so RTK Query answered from its cache, and the cachedsettingsData.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 inuse-upload-conflict-modal.tsxandtelemetry-drain-loader.ts. Both menu entries use this hook. ThefullPathfallback 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:
{ subscribe: false }there. Resolve it to{ forceRefetch: true, subscribe: false }, otherwise the fix is lost on 2026.x.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 currentsettingsData.urlafter it changed (with a mock that behaves like the RTK cache), and falls back tofullPath. The first two fail without the fix.Verified
check-types,lint,npm test(1224 tests on 2026.3) andbuild-apppass.Not verified
The build output is not part of this PR.
🤖 Generated with Claude Code