Skip to content

Commit

Permalink
Merge pull request #3651 from serlo/e2e-fix-breadcrumbs
Browse files Browse the repository at this point in the history
fix: breadcrumbs for all uppermost taxonomies
  • Loading branch information
elbotho authored Apr 15, 2024
2 parents a113ec9 + f7ed4a5 commit b8cf98b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
10 changes: 6 additions & 4 deletions apps/web/src/fetcher/create-breadcrumbs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ export function taxonomyParentsToRootToBreadcrumbsData(

const { secondaryMenus } = getInstanceDataByLang(instance)

if (!term.path) return undefined

let breadcrumbs = term.path.map((entry) => {
return {
label: entry!.title,
Expand All @@ -52,19 +54,19 @@ export function taxonomyParentsToRootToBreadcrumbsData(
}
})

if (!breadcrumbs?.length) return undefined

if (includeFirstParent) {
if (includeFirstParent || !term.path.length) {
breadcrumbs.push({
label: term.title,
url: term.alias,
id: term.id,
})
}

if (!breadcrumbs?.length) return undefined

// get the subject from the secondary menu data so we link to the correct landing pages
const subject = secondaryMenus.find(
(menu) => menu.rootId === breadcrumbs[0].id
(menu) => menu.rootId === breadcrumbs[0]?.id ?? term.id
)

if (subject) {
Expand Down
6 changes: 5 additions & 1 deletion apps/web/src/fetcher/create-secondary-menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ export function createSecondaryMenu(
if (uuid.__typename === UuidType.TaxonomyTerm) {
if (uuid.type === TaxonomyTermType.ExerciseFolder) return undefined

const breadcrumbs = taxonomyParentsToRootToBreadcrumbsData(uuid, instance)
const breadcrumbs = taxonomyParentsToRootToBreadcrumbsData(
uuid,
instance,
true
)

if (!breadcrumbs) return undefined

Expand Down

0 comments on commit b8cf98b

Please sign in to comment.