Preview pane not working for Page type in custom desk structure
I can see the issue! In your desk structure, you're setting up custom views for the Global Settings document (which works), but for Pages, you're only defining list items and filtered document lists without specifying the views for individual page documents.
The key missing piece is a defaultDocumentNode resolver that tells Sanity Studio what views to show when opening a Page document. Here's how to fix it:
import LoeSettingsPreview from "./preview-components/LoeSettingsPreview";
import PagePreview from "./preview-components/PagePreview";
export const loeStructure = (S, context) =>
S.list()
.title('LOE Content')
.items([
S.listItem()
.title("Global Settings")
.schemaType("loeSetting")
.icon(MdSettings)
.child(
S.editor()
.schemaType("loeSetting")
.documentId("loeSetting")
.views([
S.view.form(),
S.view.component(LoeSettingsPreview).title("Preview"),
])
),
S.listItem()
.title("Pages")
.icon(SiLibreoffice)
.child(
S.list()
.title("Filters")
.items([
// ... your existing list items
])
),
]);
// Add this defaultDocumentNode resolver
export const loeDefaultDocumentNode = (S, { schemaType }) => {
if (schemaType === 'page') {
return S.document().views([
S.view.form(),
S.view.component(PagePreview).title("Preview"),
]);
}
return S.document();
};Then in your sanity.config.js (or .ts), you need to pass both the structure AND the defaultDocumentNode to your desk configuration:
import { loeStructure, loeDefaultDocumentNode } from './deskStructure';
export default defineConfig({
// ... other config
plugins: [
structureTool({
structure: loeStructure,
defaultDocumentNode: loeDefaultDocumentNode,
}),
],
});The defaultDocumentNode resolver is what controls the views for documents when they're opened from lists. Your Global Settings works because you explicitly defined the views in the .child() call with S.editor().views(), but for Page documents that come from document lists (like "All Pages", "Draft Pages", etc.), you need the defaultDocumentNode to specify those views.
This is a common migration gotcha from v2 to v3 - the structure API is similar but the configuration pattern in the config file changed slightly. The key difference is that individual document views for list items need to be handled by defaultDocumentNode rather than being inherited automatically.
Show original thread15 replies
Sanity – Build the way you think, not the way your CMS thinks
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.