From b5b5131eeef9f4260a4902282053aed15420aa1f Mon Sep 17 00:00:00 2001 From: gnezim Date: Wed, 22 Apr 2026 03:07:55 +0300 Subject: [PATCH] Emit document title on error pages (404/500) per TZ 4.1.21 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously the 404/500 React ErrorPage set the page content but not document.title, so the browser tab showed the URL path instead of a localized title. Added element + imperative document.title assignment (pattern from SeoHead.tsx) so both SSR and client set the tab title to "<code> — <localized-title>", e.g. "404 — Страница не найдена". --- src/ui/errors/ErrorPage.tsx | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/ui/errors/ErrorPage.tsx b/src/ui/errors/ErrorPage.tsx index 555bbcaf..4f39e668 100644 --- a/src/ui/errors/ErrorPage.tsx +++ b/src/ui/errors/ErrorPage.tsx @@ -120,9 +120,19 @@ export function ErrorPage({ code }: ErrorPageProps): JSX.Element { const support = translations?.support ?? "Поддержка"; const refresh = translations?.refresh ?? (config.refreshKey ? "Обновить страницу" : undefined); const displayCode = code ?? "?"; + const documentTitle = `${displayCode} — ${title}`; + + // React 18 doesn't hoist <title> inside body to document.head, so set + // document.title imperatively on the client once translations resolve. + useEffect(() => { + if (typeof document !== "undefined" && translations) { + document.title = documentTitle; + } + }, [documentTitle, translations]); return ( <> + <title>{documentTitle} {/* noindex: error pages must not be indexed (TZ §4.1.21) */}