Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: resolves issue with treenav in production #1508

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
// branch node with more than 1 leaf nodes
if (item.pages && item.pages.length > 1) {
item.isBranch = true;
item.pages.forEach((SubNavItem, i) => assignNodeType(SubNavItem));

Check warning on line 29 in packages/gatsby-theme-carbon/src/components/LeftNav/LeftNavTree.js

View workflow job for this annotation

GitHub Actions / validate-and-build

'i' is defined but never used. Allowed unused args must match /res|next|^err|^_/u
}
// if it is branch node with only one leaf node, convert it to a leaf node
else if (item.pages && item.pages.length) {
Expand Down Expand Up @@ -66,7 +66,10 @@
useEffect(() => {
const stripTrailingSlash = (str) =>
str.endsWith('/') ? str.slice(0, -1) : str;
setActivePath(stripTrailingSlash(location.pathname));
const base = process.env.PATH_PREFIX
? location.pathname.split(process.env.PATH_PREFIX)[1]
: location.pathname;
setActivePath(stripTrailingSlash(base));
}, [location.pathname]);

const getItemPath = (item) =>
Expand Down Expand Up @@ -97,7 +100,7 @@
activeNode = dfs(itemNodes, isTabActive);
}
setTreeActiveItem(activeNode);
}, [isTreeNodeActive, itemNodes]);

Check warning on line 103 in packages/gatsby-theme-carbon/src/components/LeftNav/LeftNavTree.js

View workflow job for this annotation

GitHub Actions / validate-and-build

React Hook useEffect has a missing dependency: 'isTabActive'. Either include it or remove the dependency array

const isTreeNodeExpanded = (node) =>
!!dfs([node], (evalNode) =>
Expand Down Expand Up @@ -168,6 +171,6 @@
),
};

const areEqual = (prevProps, nextProps) => true;

Check warning on line 174 in packages/gatsby-theme-carbon/src/components/LeftNav/LeftNavTree.js

View workflow job for this annotation

GitHub Actions / validate-and-build

'prevProps' is defined but never used. Allowed unused args must match /res|next|^err|^_/u

export default memo(LeftNavTree, areEqual);
4 changes: 2 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10595,7 +10595,7 @@ __metadata:
dependencies:
"@carbon/icons-react": "npm:^11.43.0"
gatsby: "npm:^5.13.6"
gatsby-theme-carbon: "npm:^4.0.7"
gatsby-theme-carbon: "npm:^4.0.8"
react: "npm:^18.3.1"
react-dom: "npm:^18.3.1"
languageName: unknown
Expand Down Expand Up @@ -11905,7 +11905,7 @@ __metadata:
languageName: unknown
linkType: soft

"gatsby-theme-carbon@npm:^4.0.7, gatsby-theme-carbon@workspace:packages/gatsby-theme-carbon":
"gatsby-theme-carbon@npm:^4.0.8, gatsby-theme-carbon@workspace:packages/gatsby-theme-carbon":
version: 0.0.0-use.local
resolution: "gatsby-theme-carbon@workspace:packages/gatsby-theme-carbon"
dependencies:
Expand Down
Loading