Problem/Motivation

Active trails are not calculated correctly for menu items created with views. This is caused by the the fact that view page routes contain the view_id and display_id parameters, which are not saved in the menu_tree table.

Steps to reproduce

1. Install a site with the olivero theme
2. Create a view page
3. In the view settings, under Page settings > Menu, add Normal menu entry under main menu
4. Visit the view page
5. Inspect the HTML of the menu link. The link does not have any active trail classes (e.g. is-active)

Proposed resolution

Change the way views menu links are saved. They should also store the view_id and display_id parameters.

Comments

stefan.butura created an issue. See original summary.

stefan.butura’s picture

StatusFileSize
new843 bytes

Patch attached. Requires a cache rebuild.

larowlan’s picture

Status: Active » Closed (duplicate)

This is a duplicate of #3359511: [regression] missing menu active trail since Drupal 9.5.9
But your patch seems simpler. Let's discuss over there?

shabana.navas’s picture

This patch is a great and simple fix. However, it does not work for Views that have contextual filters.

vurt’s picture

I can confirm that the patch works as expected. Thank you.