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

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

jpk27 created an issue. See original summary.

sriram s made their first commit to this issue’s fork.

sriram s’s picture

Status: Active » Needs review

Opened MR !168 with a fix + test. Set to Needs review.

phpcs failures are pre-existing (unrelated methods in the test file) — the fix and new test are clean.

greg boggs’s picture

Status: Needs review » Fixed

Hey, you're awesome. Thanks for the fix. Looks good. Keep it up.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.