Breadcrumbs from menu titles get corrupted when menu contains anchor-links

Created on 4 March 2025, about 1 month ago

Hello,

I am encountering some unexpected behaviour when applying the 'Use menu title when available' option in combination with menus whose items are anchor-links (i.e. that link to sections on a page, rather than a page itself). Probably best described with an example.

I have a page that is a list of publications, grouped into sections by year; each year-heading has an id attribute so that it can be used as the target for an anchor-link. The relative URL for the page is just /publications. This page has a corresponding menu-item in the main menu named 'publications', beneath which is a sub-menu consisting of anchor-links to the year-sections in the page (so '2024' --> /publications#2024, '2023' --> /publications#2023 etc).

The resulting breadcrumb for the page is 'Home' -> '2008' (2008 being the first year in the list). This breadcrumb appears irrespective of whether one clicks on the main 'publications' menu-item, or on one of the items in the sub-menu. The desired breadcrumb would simply be 'Home' -> 'Publications', or perhaps 'Home' -> 'Publications' -> '' if one had clicked on the sub-menu item '' (although the latter probably doesn't make sense if the breadcrumb is always only visible at the top of the page).

So I feel like something is becoming a bit confused when the menu links contain anchors (i.e. hash characters). I'm a total PHP novice, so I've not much hope of understanding this by myself. Any assistance would be very welcome.

Thanks a lot, John

🐛 Bug report
Status

Active

Version

2.0

Component

Code

Created by

🇬🇧United Kingdom jpk27

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024