Skip to content

Commit

Permalink
Merge pull request #307 from newrelic/jerel/nav-expansion
Browse files Browse the repository at this point in the history
Fix nav not collapsing for some pages
  • Loading branch information
jerelmiller authored Jun 29, 2020
2 parents 6c5eeb7 + 16e1d3a commit 0fc7dd2
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions gatsby/wrap-page-element.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable react/prop-types */
import React from 'react';
import { BreadcrumbContext } from '../src/components/BreadcrumbContext';
import { PageContext } from '../src/components/PageContext';
Expand Down
2 changes: 1 addition & 1 deletion src/components/NavigationItems.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ button.navLink {
}

.isCurrentPage {
font-weight: bold;
font-weight: bold !important;
}

.filterOn {
Expand Down
8 changes: 7 additions & 1 deletion src/utils/create-breadcrumbs.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const URL_WITH_TRAILING_SLASH = /(.+)\/$/;

/**
* Create a flat array of breadcrumbs for a given relative url given the
* site structure (sidenav). Returns an empty array if no match found. NOTE:
Expand All @@ -20,7 +22,11 @@ const createBreadcrumbs = (url, links, result = []) => {
}

// check to see if any of the links at this level match the path
const match = links.find((link) => link.url === url);
const match = links.find(
(link) =>
link.url === url ||
link.url === url.replace(URL_WITH_TRAILING_SLASH, '$1')
);

// if we have a link, return the displayName at the end of the result
if (match) {
Expand Down

0 comments on commit 0fc7dd2

Please sign in to comment.