Visitar URL original
fix(devtools): prevent root route from being marked as active for nes… by MeAkib · Pull Request #63498 · angular/angular · GitHub
The Wayback Machine - https://web.archive.org/web/20250924130951/https://github.com/angular/angular/pull/63498
Skip to content

Conversation

MeAkib
Copy link
Contributor

@MeAkib MeAkib commented Aug 30, 2025 •

Fixed: #63493

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • angular.dev application / infrastructure changes
  • Other... Please describe:

What is the current behavior?

Issue Number:
#63493

What is the new behavior?

Does this PR introduce a breaking change?

  • Yes
  • No

…ted routes

Fix route detection logic to only mark root route (/) as active when URL is exactly "/"
@pullapprove pullapprove bot requested a review from dgp1130 August 30, 2025 07:30
@ngbot ngbot bot added this to the Backlog milestone Aug 30, 2025
const pathWithoutParams = routePath.split('/:')[0];
const isActive = currentUrl?.startsWith(pathWithoutParams);
const isActive =
routePath === '/' ? currentUrl === '/' : currentUrl?.startsWith(pathWithoutParams);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this problem is unique to /, couldn't the same thing happen if you have a route with /foo and another route at /foo/bar? In that scenario, I think visiting /foo/bar would highlight both /foo and /foo/bar.

I wonder if we should try to do a more complete match here? Not sure how complicated that would be. @AleksanderBodurri, what do you think?

Copy link
Member

@AleksanderBodurri AleksanderBodurri Sep 21, 2025 •

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, I think our "is this route active" logic needs an overhaul. The current approach seems too brittle. This PR addresses one of the gaps but I think we need a better solution.

Maybe we can create a debug API wrapper around https://angular.dev/api/router/Router#isActive and use it to determine which router tree nodes are active.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Home Route is always shown as active in Angular DevTools
3 participants