-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Undefined context for '/' nested routes #1404
Comments
+1 I am experiencing the same behavior re: undefined context at the '/' index leaf route. I've got the connectOutlets call on the /:company route rather than the '/' to get things serializing and deserializing properly, but I expect to run into the same issue jumping from leaf to leaf without hitting the parent in between. EDIT: the null '/' context issue is not actually a problem for me - not calling connectOutlets on the parent route was. I was misinterpreting the null context phenomenon described above as my problem, but my root issue was setting up my connectOutlets with data fetching on the leaf route rather than the parent route, e.g.,
This was causing views not to be inserted when reloading the page from a leaf state and deserializing as well (because their parent view was never inserted). To fix, I replaced it with:
Even though there is no context at the leaf route, the content property was set on the parent controller by the parent route, and thus in the absence of context / content, the view inherits this. Navigating directly between leaf states seems to be working. I can link from root.storefronts.storefront.edit directly to root.storefronts.storefront.index, as they are both inheriting the context from the parent (maybe). I still don't understand what purpose the connectOutlets call on root.storefronts.index serves... |
This has come up in various discussions a few times. I think it's on @wycats radar for router v2 that is being worked on right now. |
@wagenet at the very least this bug is verified. |
This issue is addressed in Router v2 😄 |
Great stuff, thank you! |
For app with a structure similar to
/:company/:person
(e.g./apple/bob
) we must have nested routes but each navigate-able route must be a leaf node. So we must have a route with two sub-routes (oneindex
with route of'/'
and oneperson
with route of'/:person'
) - example below:The problem is that the
connectOutlet
for theindex
route receives acompanyContext
ofundefined
. It's actually the parentcompany
route which gets the correctcompanyContext
.This jsfiddle show how the leaf
'/'
route gets anundefined
context while the parent'/:company'
route gets the expected context.http://jsfiddle.net/xcCUK/6/ (JS bin illustrates url change better - http://jsbin.com/izefed/1)
It also illustrates that as a result of doing the
connectOutlet
at the parent route is that navigating from theperson
route (route.company.person
) to theindex
route (root.company.index
) doesn't work as the requiredconnectOutlet
in thecompany
route (route. company
) is never fired.Ideally if the
/
route was treated as a special case and the parents context was passed to it then this should solve the problem.This is somewhat, but not fully related to issue #1334. or at least being able to access other context would certainly alleviate some of the pains of this issue.
The text was updated successfully, but these errors were encountered: