diff --git a/packages/sanity/src/structure/panes/document/DocumentPaneProvider.tsx b/packages/sanity/src/structure/panes/document/DocumentPaneProvider.tsx index f341b40dd51b..eb17a124f235 100644 --- a/packages/sanity/src/structure/panes/document/DocumentPaneProvider.tsx +++ b/packages/sanity/src/structure/panes/document/DocumentPaneProvider.tsx @@ -73,7 +73,7 @@ import {usePreviewUrl} from './usePreviewUrl' */ // eslint-disable-next-line complexity, max-statements export const DocumentPaneProvider = memo((props: DocumentPaneProviderProps) => { - const {children, index, pane, paneKey, onFocusPath} = props + const {children, index, pane, paneKey, onFocusPath, perspectiveOverride} = props const schema = useSchema() const templates = useTemplates() const {setDocumentMeta} = useCopyPaste() @@ -105,7 +105,7 @@ export const DocumentPaneProvider = memo((props: DocumentPaneProviderProps) => { const params = useUnique(paneRouter.params) || EMPTY_PARAMS const {perspective, currentGlobalBundle} = usePerspective() - const bundlePerspective = resolveBundlePerspective(perspective) + const bundlePerspective = perspectiveOverride ?? resolveBundlePerspective(perspective) /* Version and the global perspective should match. * If user clicks on add document, and then switches to another version, he should click again on create document. diff --git a/packages/sanity/src/structure/panes/document/types.ts b/packages/sanity/src/structure/panes/document/types.ts index 7ea5a6f840d4..d995d00ce4d9 100644 --- a/packages/sanity/src/structure/panes/document/types.ts +++ b/packages/sanity/src/structure/panes/document/types.ts @@ -9,4 +9,9 @@ export type TimelineMode = 'since' | 'rev' | 'closed' export type DocumentPaneProviderProps = { children?: React.ReactNode onFocusPath?: (path: Path) => void + /** + * The perspective is normally determined by the router. The `perspectiveOverride` prop can be + * used to explicitly set the perspective, overriding the perspective provided by the router. + */ + perspectiveOverride?: string } & BaseStructureToolPaneProps<'document'>