Menu Breadcrumb relies upon MenuActiveTrail::getActiveTrailIds to get the active trail for the current page, using the route passed to the breadcrumb builder, but this is returning an empty array (not including a null string at the end) for Views pages and therefore an empty breadcrumb trail.

Nothing in this function says that it shouldn't work on views. Menu Breadcrumb has been using this method of getting the active trail since its Alpha release and nobody's reported that it doesn't work on views. I only noticed it now since somehow the Frontpage view does show an active trail from getActiveTrailIds() when it's not the front page of the site, which is the typical blog configuration that we use.

So this problem can be easily reproduced by installing a new site, adding the current Menu Breadcrumb module, and adding a node and a built-in (e.g., Archive) view side by side on the main menu (except for Taxonomy views which are working normally, maybe because they have contextual links which force them to have more explicit parameters?). The node will have a breadcrumb for the current page, and the view won't. In fact, that view won't have any menu breadcrumbs even if deep in a submenu since its active trail will be empty no matter what.

Using MenuActiveTrail::getActiveLink instead, or the method they ultimately call (MenuLinkManager::loadLinksByRoute), still returns the empty array. Since loadLinksByRoute() explicitly takes a route & parameters, it must be that these arguments, as passed to the breadcrumb builder, are not sufficient to identify the active trail for views: even under typical circumstances like putting one of the default views on the Main Navigation menu.

Comments

rphair created an issue. See original summary.

rphair’s picture

Issue summary: View changes

(slightly more detail about why some view pages might have active trail anyway)

rphair’s picture

Priority: Major » Normal
Related issues: +#2820751: Menu Active Trail is empty for built-in view pages

I have done a lot more testing on this, and problem appears isolated to the two builtin Page views Archive and Glossary. I have filed this core issue; testing suggests this is caused by views having a single NULL argument that causes the menu active trail service to return an empty active trail & also asking what would be an acceptable workaround for use in this module.

rphair’s picture

Title: No active trail for views » No active trail for views with a NULL parameter
rphair’s picture

Status: Active » Postponed (maintainer needs more info)
Issue tags: +blocked

No response about core issue yet, but will monitor it & update this issue accordingly as soon as there is movement on that one.

rphair’s picture

Status: Postponed (maintainer needs more info) » Postponed
rphair’s picture

This core issue is still present in Drupal 8.3.1 - I've updated the related core issue as such. If I had to work around this bug I would recreate the Archive and/or Glossary views from the UI according to the observable configuration of those views. It just seems to be those views as loaded from the default config that are broken for breadcrumbs (i.e., don't generate a menu active trail).

rphair’s picture

Status: Postponed » Closed (works as designed)

I've just tested this with a fresh 8.6.1 installation: the built-in views with NULL parameters (Archive and Glossary) still show up with an empty active trail and therefore no breadcrumbs. I'm closing this after a long time of monitoring that core issue since it now seems the absent active trail for these built-in views is somehow by design, or has become so now that the anomaly has become institutionalised.

Therefore it makes no sense for a problem to be flagged in this module when it's either a core or default config problem. A workaround at the site building level would be to rebuild the Glossary and/or Archive views by hand if they need to have working breadcrumbs based on the menu active trail.