
Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag storeI understand your frustration! This is a known behavior in Sanity Studio where the global search and Structure tool navigation work somewhat independently. When you navigate through the Structure tool's menu, your custom defaultDocumentNode configuration is applied correctly, but when you use the global search, Studio can sometimes open documents in a default view that bypasses your custom configuration.
The Solution:
The good news is that your defaultDocumentNode configuration in the structureTool() plugin should apply to all document opens, including those from search results. Based on the Structure Builder documentation, here's how to ensure it works properly:
Make sure your defaultDocumentNode is configured at the plugin level in your sanity.config.ts:
// sanity.config.ts
import {defineConfig} from 'sanity'
import {structureTool} from 'sanity/structure'
export default defineConfig({
// ... other config
plugins: [
structureTool({
defaultDocumentNode: (S, {schemaType}) => {
// Apply your custom preview to your document type
if (schemaType === 'word') { // or whatever your doc type is called
return S.document().views([
S.view.component(YourCustomPreview).title('Display'),
S.view.form().title('Editor')
])
}
return S.document()
},
structure: (S) => {
// your structure configuration
}
})
]
})Key points to fix your issue:
Order matters: If you want the preview to be the default view (the one that shows first), list it first in the views array. This ensures when documents open from search, they show your custom preview first.
Plugin-level configuration: Ensure defaultDocumentNode is at the plugin level in structureTool(), not nested within specific structure items.
Don't override in structure: If you're defining specific document nodes within your structure configuration for the same document type, those will take precedence over defaultDocumentNode. Make sure you're not inadvertently overriding it.
Check for the view tabs: The tabs (Display, Editor) should appear for documents opened from search just as they do from navigation. If they're missing entirely, there might be a configuration conflict.
The defaultDocumentNode at the plugin level should apply universally to all document opens, whether from the structure navigation or global search. If you're still experiencing issues after confirming this setup, it might be worth checking if there are any Studio version-specific quirks or reaching out to the Sanity community with your specific Studio version and configuration.
Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.
Content operations
Content backend


The only platform powering content operations
By Industry


Tecovas strengthens their customer connections
Build and Share

Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag store