diff --git a/scm-ui/ui-components/src/layout/Title.tsx b/scm-ui/ui-components/src/layout/Title.tsx index f512753051..9532cdc639 100644 --- a/scm-ui/ui-components/src/layout/Title.tsx +++ b/scm-ui/ui-components/src/layout/Title.tsx @@ -1,17 +1,30 @@ -import React from "react"; +import React, { FC, useEffect } from "react"; type Props = { title?: string; + customPageTitle?: string; + preventRefreshingPageTitle?: boolean; }; -class Title extends React.Component { - render() { - const { title } = this.props; - if (title) { - return

{title}

; +const Title: FC = ({ title, preventRefreshingPageTitle, customPageTitle }) => { + useEffect(() => { + if (!preventRefreshingPageTitle) { + if (customPageTitle) { + document.title = customPageTitle; + } else if (title) { + document.title = title; + } } - return null; + }); + + if (title) { + return

{title}

; } -} + return null; +}; + +Title.defaultProps = { + preventRefreshingPageTitle: false +}; export default Title;