diff --git a/packages/sanity/src/core/config/types.ts b/packages/sanity/src/core/config/types.ts index adcb9bb78da0..cf20a86f5b47 100644 --- a/packages/sanity/src/core/config/types.ts +++ b/packages/sanity/src/core/config/types.ts @@ -141,6 +141,11 @@ export interface Tool { */ title: string + /** + * Determines whether the tool will control the document title. + */ + controlsDocumentTitle?: boolean + /** * Gets the state for the given intent. * diff --git a/packages/sanity/src/core/studio/StudioLayout.tsx b/packages/sanity/src/core/studio/StudioLayout.tsx index 4b3855f0f7ba..3266ad4f9962 100644 --- a/packages/sanity/src/core/studio/StudioLayout.tsx +++ b/packages/sanity/src/core/studio/StudioLayout.tsx @@ -89,14 +89,14 @@ export function StudioLayout() { return mainTitle }, [activeToolName, name, title]) + const toolControlsDocumentTitle = !!activeTool?.controlsDocumentTitle useEffect(() => { - if (activeToolName === 'content') { - // Will be handled by sanity/src/desk/components/deskTool/DeskTitle.tsx + if (toolControlsDocumentTitle) { return } document.title = documentTitle - }, [documentTitle, activeToolName]) + }, [documentTitle, toolControlsDocumentTitle]) const handleSearchFullscreenOpenChange = useCallback((open: boolean) => { setSearchFullscreenOpen(open) diff --git a/packages/sanity/src/desk/deskTool.ts b/packages/sanity/src/desk/deskTool.ts index 8ae9a53e33b3..896451f37dbd 100644 --- a/packages/sanity/src/desk/deskTool.ts +++ b/packages/sanity/src/desk/deskTool.ts @@ -107,6 +107,8 @@ export const deskTool = definePlugin((options) => ({ (intent === 'create' && params.template), ) }, + // Controlled by sanity/src/desk/components/deskTool/DeskTitle.tsx + controlsDocumentTitle: true, getIntentState, options, router,