angular-route-segment icon indicating copy to clipboard operation
angular-route-segment copied to clipboard

On page refresh, deeper segments don't always render

Open Orppa opened this issue 10 years ago • 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.

Orppa avatar Oct 03 '14 09:10 Orppa

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

muvic08 avatar Nov 18 '14 01:11 muvic08

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.

Orppa avatar Nov 18 '14 11:11 Orppa

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

muvic08 avatar Nov 18 '14 13:11 muvic08

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.

Orppa avatar Nov 18 '14 13:11 Orppa

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

ghost avatar Nov 20 '14 20:11 ghost

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.

ghost avatar Nov 20 '14 22:11 ghost

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.

leoetlino avatar Jul 13 '15 13:07 leoetlino