artch/angular-route-segment

On page refresh, deeper segments don't always render

Opened this issue · 7 comments

When there is more segments in the chain than 1 and you refresh the page, sometimes the second level template doesn't render. This seems to be the result of promises and when they resolve.

Using version 1.3.3 and it seems that reload on line 403 is called and when it returns the promise, it broadcasts the index of the resolved chain element, which triggers update for that segment in view.

If we get earlier element resolved after the last in chain is rendered, it re-renders the earlier element and loses the later chain element that was rendered inside it.

I am having the same problem. Orppa, were you able to fix it?

I have a working version here: https://github.com/Orppa/angular-route-segment

Don't think it's the best fix for the issue, that's why there is no pull request about it, but so far has solved the problem without any side effects.

So try that and see if it solves the problem for you.

Thank you very much but the link you shared just takes me to a fork of the main branch. Am I missing something?

It's a fork with my fix for the issue applied. Not the best fix for sure, but solves the issue and hasn't caused any problems that we would notice.

The fix is applied straight to build version, not to source, as this is not meant to be published publicly. It's just to solve the problem untill a proper fix would come from the maintainer.

I'm having the same problem too, I'll try to isolate in a plunkr

I just isolated the problem, this happens only when also using ui-bootstrap, and the content is nested inside a tab, the tab fires a select after the route is already loaded. I solved this by having the tab select function check if the path is already loaded before routing to it.

Can confirm that the fix by @Orppa works (with some minor changes to make it work with recent versions).

/*if(result.success != undefined)
broadcast(index);*/

This is the code that should be commented to fix it.

It does incur some side-effects, like the segment view not reloading when the watcher changes, but this is better than having a part of the application missing randomly.