Describe the bug
When using the "Open In Studio" links, the published perspective is chosen even when viewing draft content (including if there is only a draft version and no published version)
To Reproduce
I have reproduced this using the https://www.sanity.io/templates/nextjs-sanity-clean template using the example data:
- Make a change to the about page (e.g. add
Draft to the start of the heading)
- Go to the Presentation section in Studio to enable preview on the Next website
- View the about page on Next website http://localhost:3000/about
- You will see the
Draft next in the heading
- Click on the "Open In Studio" link
- Studio is opened in the Published Perspective and therefore doesn't display the
Draft text.
See screenshots below.
Expected behavior
If I'm previewing draft content then this should be the perspective used when opened in Studio. I'm not really sure I understand when I would want to go to the published perspective? If I'm using preview mode on the website, the preview content will be what's displayed.
Screenshots
Draft version of about page:
Click on Open In Studio (draft version displayed) of about page:
Published perspective is shown in Studio:
Which versions of Sanity are you using?
Run sanity versions in the terminal and copy-paste the result here.
@sanity/cli (global) 3.97.1 (latest: 4.0.1)
What operating system are you using?
macOS Sequoia
Which versions of Node.js / npm are you running?
Run npm -v && node -v in the terminal and copy-paste the result here.
Additional context
This PR #979 seems to have added the published perspective when the ID is a non-draft ID.
However, the id being passed to this function seems to always be the published ID.
I haven't reviewed the Stega code, but I can see the createDataAttribute function always includes the published ID:
https://github.com/sanity-io/visual-editing/blob/965dff164d73aa39a85a3b627c71f46f52bbfe88/packages/visual-editing-csm/src/encodeSanityNodeData.ts#L20
Describe the bug
When using the "Open In Studio" links, the published perspective is chosen even when viewing draft content (including if there is only a draft version and no published version)
To Reproduce
I have reproduced this using the https://www.sanity.io/templates/nextjs-sanity-clean template using the example data:
Draftto the start of the heading)Draftnext in the headingDrafttext.See screenshots below.
Expected behavior
If I'm previewing draft content then this should be the perspective used when opened in Studio. I'm not really sure I understand when I would want to go to the published perspective? If I'm using preview mode on the website, the preview content will be what's displayed.
Screenshots
Draft version of about page:
Click on Open In Studio (draft version displayed) of about page:
Published perspective is shown in Studio:
Which versions of Sanity are you using?
Run
sanity versionsin the terminal and copy-paste the result here.@sanity/cli (global) 3.97.1 (latest: 4.0.1)What operating system are you using?
macOS Sequoia
Which versions of Node.js / npm are you running?
Run
npm -v && node -vin the terminal and copy-paste the result here.Additional context
This PR #979 seems to have added the
publishedperspective when the ID is a non-draft ID.However, the id being passed to this function seems to always be the published ID.
I haven't reviewed the Stega code, but I can see the
createDataAttributefunction always includes the published ID:https://github.com/sanity-io/visual-editing/blob/965dff164d73aa39a85a3b627c71f46f52bbfe88/packages/visual-editing-csm/src/encodeSanityNodeData.ts#L20