From 8281d491568eb0a73a370e065c8929eb6334768d Mon Sep 17 00:00:00 2001 From: Zak Burke Date: Tue, 24 Sep 2024 17:24:50 +0100 Subject: [PATCH] STCOR-767 restore correct page titles PR #1532 inadvertently undid the work of PR #1377. This restores it. Refs STCOR-767, STCOR-875 --- src/components/TitleManager/TitleManager.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/components/TitleManager/TitleManager.js b/src/components/TitleManager/TitleManager.js index 6058724e7..4b21c2532 100644 --- a/src/components/TitleManager/TitleManager.js +++ b/src/components/TitleManager/TitleManager.js @@ -21,15 +21,25 @@ class TitleManager extends React.Component { static defaultProps = { prefix: '' } renderTitle = (currentTitle) => { - const { prefix, page, record } = this.props; + const { prefix, page, record, stripes } = this.props; + const postfix = stripes.config?.platformName || APP; if (typeof currentTitle !== 'string') return ''; const tokens = currentTitle.split(' - '); + + /** + * When there are 2 items - that means there are page and postfix. + * If we don't clear the tokens[1] item then we'll have two postfixes - in tokens[1] and tokens[2] will be added later + */ + if (tokens.length === 2) { + tokens[1] = ''; + } + if (page) tokens[0] = page; if (record) tokens[1] = record; - tokens[2] = (this.props.stripes.config || {}).platformName || APP; + tokens[2] = postfix; return prefix + tokens .filter(t => t) @@ -45,4 +55,4 @@ class TitleManager extends React.Component { } } -export default withStripes(TitleManager); +export default withStripes(TitleManager); \ No newline at end of file