Skip to content

Commit 94056b7

Browse files
authored
Merge pull request #2352 from topcoder-platform/legacy-tco
Fix menus bug for root paths
2 parents 91d9558 + e4ef842 commit 94056b7

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

src/shared/components/Contentful/Menu/Menu.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
*
44
*/
55
/* global window */
6+
import _ from 'lodash';
67
import React from 'react';
78
import PT from 'prop-types';
89
import Dropdown from 'components/tc-communities/Dropdown';
@@ -17,7 +18,7 @@ export default function Menu(props) {
1718
} = props;
1819

1920
if (isomorphy.isClientSide()) {
20-
if (baseUrl === parentBaseUrl && baseUrl !== window.location.pathname) {
21+
if (baseUrl && baseUrl === parentBaseUrl && baseUrl !== _.trimEnd(window.location.pathname, '/')) {
2122
return null;
2223
}
2324
} else {

src/shared/components/Contentful/Route.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ function ChildRoutesLoader(props) {
5858
preview={preview}
5959
spaceName={spaceName}
6060
environment={environment}
61+
baseUrl={url}
6162
/>
6263
) : <Error404 />
6364
}

src/shared/utils/contentful.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,7 @@ export function isActive(baseUrl, item, caller) {
6464
}
6565

6666
// handles the special case when url === `/`
67-
if (caller === 'menuItem' && item
68-
&& (item.fields.url === '/' || !item.fields.url)
67+
if (caller === 'menuItem'
6968
&& to === baseUrl
7069
&& (location !== to && location !== `${to}/`)) {
7170
return false;

0 commit comments

Comments
 (0)