Active trail is cached incorrectly

Created on 15 April 2021, about 4 years ago
Updated 18 July 2024, 11 months ago
  • Create a group menu containing at least 2 menu items and place the menu on the page using the block made available by Group Content Menu's GroupMenuBlock plugin.
  • Use a menu.html.twig template that leverages the value of item.in_active_trail (I'll attach an example).
  • Load the page for the first menu link and observe the menu is rendered and the correct link is in the active trail
  • Load the page for the second menu link and observe the menu is rendered, but the first link is still considered part of the active trail and the second link isn't.

This is caused by the fact that the cache context isn't being correctly calculated. Patch coming shortly.

πŸ› Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States azinck

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • Open in Jenkins β†’ Open on Drupal.org β†’
    Core: 9.5.x + Environment: PHP 8.0 & MySQL 5.7
    last update about 2 years ago
    6 pass
  • πŸ‡ΊπŸ‡ΈUnited States jnicola

    We had this same issue. I was able to reproduce the issue with the below behat test, and with the patch in place the test is able to pass.

    I'd recommend separating out layout builder concerns. They are possibly unrelated and shouldn't bog down what is a simple cache context fix.

    Scenario: Active trail works on group menu and is cached correctly.
        Given group:
          | label            | type          | path              | status |
          | Behat test group | default_group | /behat-test-group | 1      |
        And I am logged in as a user with the "ohsu_contributor" role
        And I am a group member with the "senior_editor" role
        # Create a custom piece of content in the group with group menu.
        # @todo Replace with singular step.
        When I visit the form to create a "basic_page" in my group
        And I fill in "Title" with "Test menu 1"
        And I press the "Save" button
        # Below is equivelant to: And I check the box "Provide a menu link"
        And I check the box "field_group_content_menu_link[0][enabled]"
        And I fill in "Menu link title" with "Behat Test Gcontent Menu Link 1"
        And I fill in the meta description field as necessary
        And I press the "Add new content item" button
        Then I should see a created successfully message
        # Create ANOTHER custom piece of content in the group with group menu.
        # @todo Replace with singular step.
        When I visit the form to create a "basic_page" in my group
        And I fill in "Title" with "Test menu 2"
        And I press the "Save" button
        # Below is equivelant to: And I check the box "Provide a menu link"
        And I check the box "field_group_content_menu_link[0][enabled]"
        And I fill in "Menu link title" with "Behat Test Gcontent Menu Link 2"
        And I fill in the meta description field as necessary
        And I press the "Add new content item" button
        Then I should see a created successfully message
        # Confirm all links are in the group menu for the group.
        When I view the group with label "Behat test group"
        Then I should see the text "Behat Test Gcontent Menu Link 1" in the "group sidebar menu" region
        Then I should see the text "Behat Test Gcontent Menu Link 2" in the "group sidebar menu" region
        When I click "Behat Test Gcontent Menu Link 1" in the "group sidebar menu" region
        Then the ".nav-link.nav-link--active" element should contain "Behat Test Gcontent Menu Link 1"
        When I click "Behat Test Gcontent Menu Link 2" in the "group sidebar menu" region
        Then the ".nav-link.nav-link--active" element should contain "Behat Test Gcontent Menu Link 2"
    
    • heddn β†’ committed ec89a992 on 2.0.x
      Issue #3209011 by maurizio.ganovelli, azinck, KarlShea, heddn, jnicola:...
    • heddn β†’ committed 08e188c4 on 3.0.x
      Issue #3209011 by maurizio.ganovelli, azinck, KarlShea, heddn, jnicola:...
  • Status changed to Fixed 11 months ago
  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024