Sanity Studio v5.9.0: Fix for Presentation perspective bug and improved context awareness for schema validations

This release adds validation context for hidden fields, introduces a rule.skip() method, enables automatic schema extraction during development, allows documents to open with multiple split-pane views by default, and fixes several bugs including issues with scheduled drafts, timezone changes, text field updates, published document status, and the presentation tool.

New validation context and method

Adds new context to the validation property in the schema that includes if the field is hidden (context.hidden) for any reason (be it by the hidden condition in itself or any ancestor.)
Adds new rule method rule.skip() which will skip a validation completely.

import {defineField} from 'sanity'

export const titleField = defineField({
name: 'title',
title: 'Title',
type: 'string',
validation: (rule, context) => (context?.hidden ? rule.skip() : rule.required().min(5)),
})

Add schema extraction to dev and build commands

Schema extraction can now be performed as part of the dev and build commands. No longer necessary to run it manually.

Configure it in sanity.cli.ts as shown below.

import {defineConfig} from 'sanity'

defineConfig({
// ... rest of config
schemaExtraction: {
enabled: true
}
})

Add defaultPanes option to documents

New Structure Builder API: S.document().defaultPanes(['viewId1', 'viewId2'])

Allows configuring documents to open with multiple views displayed as split panes by default. Content editors no longer need to manually set up side-by-side editing for documents where admins have configured a default split view.

// In defaultDocumentNode resolver
export const defaultDocumentNode: DefaultDocumentNodeResolver = (S, {schemaType}) => {
if (schemaType === 'article') {
return S.document()
.views([
S.view.form().id('editor'),
S.view.component(LivePreview).id('preview').title('Preview'),
S.view.component(JSONView).id('json').title('JSON')
])
.defaultPanes(['editor', 'preview']) // Form + Preview side-by-side
}
return S.document()
}

🐛 Notable bugfixes and improvements

Fixes a bug where published Scheduled Drafts wrongly showed a Publish action which would fail.

Fixes issues when trying to change the timezone when scheduling a Content Release or Scheduled Draft.

Fixes an issue with the Portable Text Editor that could cause updates to object fields named text to end up in a nested value object on the object itself.

Fixes a crash in Presentation Tool that could happen when switching perspectives. The error message TypeError: Cannot read properties of undefined (reading 'startsWith') wasn’t very helpful, nor actionable. Good riddance! ⚡

Schema validation now warns when an array’s of property contains multiple primitive types that resolve to the same JSON type (e.g., both string and text). This helps developers catch configuration issues where Sanity cannot distinguish between array members at runtime.

Clarifies that copying document content or a field has failed when clipboard permissions have not been allowed.

Fixes an issue where sometimes when posting multiple comments the Structure tool would crash and prevent viewing comments in the document.

Fixes an issue where a document might become stale and stuck on "publishing" status when publishing a document which was recently opened.