Skip to content

Fix for #608: fixing named routes matching for default child #609

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed

Fix for #608: fixing named routes matching for default child #609

wants to merge 3 commits into from

Conversation

marcvdm
Copy link

@marcvdm marcvdm commented Aug 13, 2016

This is a fix for #608

I used an underscore as prefix to define it as a default.

@marcvdm marcvdm changed the title Fix named routes matching for default child Fix for #608: fixing named routes matching for default child Aug 13, 2016
@LinusBorg
Copy link
Member

LinusBorg commented Sep 1, 2016

Hi @marcvdm

Thank you for our work on this PR.

Unfortunately, I will have to close it, since we decided to go another route to resolve this.

A few words on the reasoning:

  • In [2.0] default named child routes not being matched #608, Evan already commented that this is expected default behaviour: If you transition to a named route, you expect to arrive exactly there, and get the route object for this route.
  • However, as again discussed in [next] Different behaviour for default subRoute when using path vs. named route #629, For the enduser this could still be confusing as a named route can behave differently that the same URL typed in the browser. So this has to be solves somehow.
  • But the solution that you propsed with this PR would mean that a dev that wants to navigate to name: 'home' would not get that route object in $route, but would implicitly(!) get the route object for the default child route. This is also undesirable as it would confuse the developer without proper knowledge of this mechanism.

Therefore, to use the solution is:

  1. Leave the current behaviour as it is,
  2. But warn the developer when he uses a named route where a default child is present.

The goal: developers should always use the named route of the default child, and simply not use the parent named route option at all.

// instead of this:
{
  path: 'parent',
  name: 'home'
  children: [
    {
      path: '',
      name: 'home.index'
    },
   // ...further children
  ]
}

// do this:
{
  path: 'parent', // no more named route here
  children: [
    {
      path: '',
      name: 'home'
    },
   // ...further children
  ]
}

@LinusBorg LinusBorg closed this Sep 1, 2016
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