PolymerElements / app-route

A modular client-side router
https://www.polymer-project.org/1.0/articles/routing.html
146 stars 66 forks source link

Child app-route not init correctly on first page load #112

Open neckaros opened 8 years ago

neckaros commented 8 years ago

Description

when directly accessing the site with a route instead of navigating from the app child route does not get data and params

Expected outcome

Child route properties should be initialized on first load

Actual outcome

data and params properties of the child app route should be populated

Steps to reproduce

using the app created from the toolkit i have a main route in the my-app element:

<app-location route="{{route}}" use-hash-as-path></app-location>
    <app-route
        route="{{route}}"
        pattern="/:page"
        data="{{routeData}}"
        tail="{{subroute}}"
        query-params="{{routeParams}}"></app-route>

in the my-app element i have an iron page that load module lazy (using this.importHref( this.resolveUrl('my-' + page + '.html'), null, null, true)) in a subpage i have another route:

 <app-route
        route="[[route]]"
        pattern="/:page/:id"
        data="{{routeData}}"
        tail="{{subroute}}"
        query-params="{{routeParams}}"></app-route>

if i start with http://localhost:8080 and go to the subpages everything work.

But i i directly enter url: http://localhost:8080/#/shows/details/tt0413573 the child app route data and query params are empty.

If i break is the ready of the child module i can see that route is correctly set but data and query params are empty. (route : prefix = /shows , path: /details/tt0413573)

So instead of getting to the correct element i get to my default page. If from there i navigate i get to the correct detail. And if i go back i do not get back to the default page but to my initially selected detail.

Browsers Affected

neckaros commented 8 years ago

I don't have the issue if i import my child link <rel="import" href="my-element.html"> instead of using this.importHref(this.resolveUrl('my-' + page + '.html'), null, null, true);

johnlim commented 8 years ago

I'm encountering the same issue albeit a different workflow. I created an issue in PSK but it's probably best to track it here. https://github.com/PolymerElements/polymer-starter-kit/issues/888

derhuebiii commented 7 years ago

Having the same problem and no solution yet. It seems like the observers in app-route-converter-behavior are not firing to update the route, as there is no _locationChanged. Is there a way to fire this manually when the site is loading? Or any other workaround or solution?

masonlouchart commented 7 years ago

Any news?