'use client' import { useEffect } from 'react' /** * Sets the browser-tab title of a custom admin view in the admin language. * * Payload takes a custom view's `meta.title` as one plain string and does not * translate it, so the server-rendered title stays in English. The view * renders this with its translated title (server side, from `req.i18n`) and * the tab follows the editor's language once the page has loaded. * * On a full page load Next streams the view's metadata in after hydration and * writes the English title back, so the title is re-applied whenever the head * changes while the view is open. */ export function DocumentTitle({ title }: { title: string }) { useEffect(() => { const apply = () => { if (document.title !== title) {document.title = title} } apply() const observer = new MutationObserver(apply) observer.observe(document.head, { characterData: true, childList: true, subtree: true }) return () => observer.disconnect() }, [title]) return null }