Skip to content

fix: Presentation connects again from the Sanity Dashboard - #243

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

damianrosellen1 merged 2 commits into
mainfrom
fix/presentation-dashboard-frame

Conversation

@damianrosellen1

@damianrosellen1 damianrosellen1 commented Oct 22, 2026 •

Copy link
Copy Markdown
Collaborator

Presentation could no longer connect in deployed Studios, without any change to the preview config. Two causes in the starter:

1. frame-ancestors blocked the Sanity Dashboard (web/next.config.ts)
Every *.sanity.studio URL now redirects into the Dashboard (www.sanity.io/@org/studio/<appId>), which frames the Studio, which frames the site. frame-ancestors is checked against every ancestor, so a policy listing only *.sanity.studio blocked the iframe. The policy has existed since April but reaches the HTML only since dd59cb3. Adds https://*.sanity.io (what Sanity's Dashboard docs recommend) and updates README / .env.example.

Live: the starter demo, farbstudio.de, stg-farbstudio, stg-zuhorn and stg-vju send the old policy.

2. DisableDraftMode left Draft Mode inside Presentation
useIsPresentationTool() turns false inside a frame after one second without a comlink connection. The component took that as "outside Presentation" and navigated to /api/draft-mode/disable. Now it only does that on a top-level page no other window opened.

Verified

  • Nested-frame harness (dashboard → studio → web): starter-style policy blocked with Framing … violates … frame-ancestors; loads once the dashboard origin is listed.
  • Local dev with a real preview secret: in an iframe the old component called /api/draft-mode/disable right after enable; the new one stays in Draft Mode. Top-level still leaves Draft Mode.
  • pnpm typecheck, pnpm lint, pnpm check:wiring.

Not verified: a live Presentation session in a logged-in Studio.

Variant-Port: #244

🤖 Generated with Claude Code

damianrosellen1 and others added 2 commits October 22, 2026 15:37
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>
`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>
Copilot AI balanced review requested due to automatic review settings October 22, 2026 13:38
@netlify

netlify Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for bef-next-sanity-starter ready!

Name Link
🔨 Latest commit 5282297
🔍 Latest deploy log https://app.netlify.com/projects/bef-next-sanity-starter/deploys/6ada11ccdf0eb3a1d97b2de2
😎 Deploy Preview https://deploy-preview-243--bef-next-sanity-starter.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

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 narrowly scoped changes address both reported failure paths without identified blocking issues, though live logged-in Presentation verification remains outstanding.

No open issues 🎉

What changed in this PR

Restores Sanity Presentation connections when the Dashboard embeds the Studio, addressing iframe permissions and premature Draft Mode cleanup.

Changes:

  • Allows Sanity Dashboard subdomains in the frame-ancestors policy.
  • Prevents automatic Draft Mode exit in frames and windows opened by another page, while retaining standalone-page cleanup.
  • Updates setup documentation to reflect the allowed Dashboard origins.
File Description
web/​src/​components/​sanity/​DisableDraftMode.tsx Guards Draft Mode cleanup in frames and opened windows.
web/​next.config.ts Allows Sanity Dashboard origins to frame the site.
web/​.env.example Documents Dashboard origins in the Studio URL guidance.
README.md Updates preview setup guidance for Dashboard embedding.

Review effort: Balanced

@damianrosellen1
damianrosellen1 merged commit 4c26529 into main Oct 22, 2026
12 checks passed
@damianrosellen1
damianrosellen1 deleted the fix/presentation-dashboard-frame 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