Skip to content

fix: Presentation connects again from the Sanity Dashboard (variant) - #244

Merged
damianrosellen1 merged 2 commits into
variant/document-levelfrom
fix/presentation-dashboard-frame-variant
Oct 22, 2026
Merged

damianrosellen1 merged 2 commits into
variant/document-levelfrom
fix/presentation-dashboard-frame-variant

Conversation

@damianrosellen1

Copy link
Copy Markdown
Collaborator

Port of #243 by git cherry-pick -x, no conflicts.

  • web/next.config.ts: frame-ancestors adds https://*.sanity.io. Every *.sanity.studio URL 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, false from useIsPresentationTool() only means the handshake has not connected within one second.

pnpm typecheck, pnpm lint, pnpm check:wiring pass on this branch.

Variant-Port: #243

🤖 Generated with Claude Code

damianrosellen1 and others added 2 commits October 22, 2026 15:38
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)

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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-ancestors directive.
  • 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

@damianrosellen1
damianrosellen1 merged commit edd3a17 into variant/document-level Oct 22, 2026
8 checks passed
@damianrosellen1
damianrosellen1 deleted the fix/presentation-dashboard-frame-variant branch October 22, 2026 14:10
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