- Issue created by @sense-design
- πΊπΈUnited States mlncn Minneapolis, MN, USA
We are running into the same thing and it feels like a pretty major gap for a module that is supposed to look at paths and not care how the paths are created.
$trail_url->getRouteName() is views.people.page and $trail_url->getRouteParameters() is view_id: "people", display_id: "page".
$this->menuLinkManager->loadLinksByRoute(), called in getActiveTrailLink(), claims that the above is not in the main menu, but it is there as a Views-provided menu link as noted by sense-design.
- Merge request !18Issue #3440116: Add if-clause for Views links in getActiveTrailLink. β (Open) created by Unnamed author
- π¬π·Greece gkffzs
Adding to what sense-design and mlncn already reported, I found out that the reason getActiveTrailLink() returns such results for View-generated links is probably because /Drupal/Core/Menu/MenuTreeStorage's loadByRoute() function searches for
route_param_key
, which View-generated links have not. I tried creating a link to the View page manually via UI and then theroute_param_key
was properly populated and the active trail worked as expected.So I searched if there is a way to populate that table field while creating it via Views, or if I can alter loadByRoute() query, and found out that there is a related core issue: [regression] missing menu active trail since Drupal 9.5.9 π [regression] missing menu active trail in Drupal 9.5.9 Needs work . I applied the latest patch (#103 as of now) π [regression] missing menu active trail in Drupal 9.5.9 Needs work to Drupal 10.4.4 and the active trail worked for Views-generated links.
However, in case someone wants to avoid patching Drupal core, I did some work on current module's getActiveTrailLink(). I added an if-clause to handle the case of Views-generated links and make it return a proper result to add active trail. I attach the patch and leave the related MR is here: https://git.drupalcode.org/project/menu_trail_by_path/-/merge_requests/18.
- π¨πSwitzerland berdir Switzerland
The constructor changes conflict with recent fixes for D11.2 compatibility. And yes, not happy with doing raw queries like that, not due to performance, but it's bad abstraction. Fine as a workaround patch, but will likely not commit this. Try to help with getting the core issue in instead.
- Status changed to Needs work
about 2 months ago 7:48am 19 May 2025 - π¬π·Greece gkffzs
OK, understood, thanks for your remarks, I will try to help with the related core issue.