Repository navigation
fix: Presentation connects again from the Sanity Dashboard (variant) - #244
Merged
damianrosellen1 merged 2 commits intoOct 22, 2026
Merged
damianrosellen1 merged 2 commits into
damianrosellen1 merged 2 commits into
Conversation
Every `*.sanity.studio` URL now redirects into the Sanity Dashboard (`www.sanity.io/@org/studio/<appId>`), which frames the Studio, which frames this site. `frame-ancestors` is checked against every ancestor, so the policy that only listed `*.sanity.studio` blocked the Presentation iframe ("Framing ... violates ... frame-ancestors"). A Studio on its own domain opened from the Dashboard sits in the same chain. The policy has been in place since April, but only reaches the HTML since dd59cb3 moved it into next.config, which is why Presentation broke without a preview config change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit 26c49b1)
`useIsPresentationTool()` turns `false` inside a frame when the comlink handshake has not connected after one second, not only outside Presentation. `DisableDraftMode` took that as "outside" and left Draft Mode, which cut Presentation off whenever the Studio was slow to connect (it now sits in the Dashboard's frame), and in the cross-site iframe the disable route cannot clear the partitioned cookie anyway. Leave Draft Mode automatically only on a top-level page that no other window opened. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit 5282297)
There was a problem hiding this comment.
🟢 Approval recommended
The focused port addresses both reported connection failures, preserves standalone Draft Mode cleanup, and has no identified blocking issues.
No open issues 🎉
What changed in this PR
Ports #243 to the document-level variant, restoring Sanity Presentation connectivity when the Studio is embedded in the Sanity Dashboard.
Changes:
- Allows Sanity Dashboard origins in the CSP
frame-ancestorsdirective. - Prevents automatic Draft Mode exit in frames and windows opened by another page while Presentation connects.
- Updates setup documentation to match the expanded framing policy.
| File | Description |
|---|---|
web/src/components/sanity/DisableDraftMode.tsx |
Restricts automatic Draft Mode exit to top-level windows without an opener. |
web/next.config.ts |
Allows https://*.sanity.io as a framing ancestor. |
web/.env.example |
Documents the Dashboard allowance alongside the Studio URL setting. |
README.md |
Updates preview setup guidance for Dashboard framing. |
Review effort: Balanced
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Port of #243 by
git cherry-pick -x, no conflicts.web/next.config.ts:frame-ancestorsaddshttps://*.sanity.io. Every*.sanity.studioURL redirects into the Sanity Dashboard, which frames the Studio, and the browser checks every ancestor.DisableDraftMode: leaves Draft Mode automatically only on a top-level page. In a frame,falsefromuseIsPresentationTool()only means the handshake has not connected within one second.pnpm typecheck,pnpm lint,pnpm check:wiringpass on this branch.Variant-Port: #243
🤖 Generated with Claude Code