Skip to content

Simplify front page active state check and fix performance#770

Merged
drale1 merged 1 commit intoDrale1/8.x/#768-Home-menu-item-does-not-get-active-state-on-front-page-in-Drupal-10from
fix/768-simplify-front-page-active-state
Feb 26, 2026
Merged

Simplify front page active state check and fix performance#770
drale1 merged 1 commit intoDrale1/8.x/#768-Home-menu-item-does-not-get-active-state-on-front-page-in-Drupal-10from
fix/768-simplify-front-page-active-state

Conversation

@jjroelofs
Copy link
Collaborator

Summary

  • Move isFrontPage() call out of the recursive dxpr_theme_menu_set_active_trail() function into the caller (dxpr_theme_preprocess_menu), passing the result as a parameter. This avoids redundant service calls on every recursion level.
  • Remove unnecessary empty string check ($item_path === '') — Drupal's <front> route resolves to / via Url::toString(), so only / needs to be matched.

Test plan

  • Verify Home menu item gets active state on front page (Drupal 10)
  • Verify other menu items still get correct active states
  • Verify nested menus still correctly propagate active trail

- Move isFrontPage() call from recursive function to caller to avoid
  redundant service calls on each recursion level
- Remove unnecessary empty string check for item path
@drale1 drale1 merged commit 7135289 into Drale1/8.x/#768-Home-menu-item-does-not-get-active-state-on-front-page-in-Drupal-10 Feb 26, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants