You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
bug: IonRouterOutlet with routerLink does not unmount routes #20543
Hello @elylucas
I realized that it does unmount if in addition to routerLink="...", I use routerDirection="back", then the page is effectively unmounted.
This is quite an unexpected behavior.
The doc mentions: Each of these components also have a routerDirection prop to explicitly set the type of page transition to use ("back", "forward", or "none").
It is not obvious to me that this above implies which values unmount the component or not. May I suggest to make it extremely clear? I was banging my head for several hours on that problem.
The idea is if you are leaving a page by going back, the state of the page no longer needs to be maintained. Contrast that by navigating between tabs or going forward from a list page to a details page, you want the same scroll position, form inputs, etc.. in place, so we keep those around in the dom and show/hide them via css.
Yes, this makes sense. However the default behavior is misleading.
imho not providing routerDirection should unmount the component, while a purposeful routerDirection="forward" should keep the component.
Now, a large part of my app uses programmatical redirections, with history.replace. history.replace does not seem to trigger an unmount. Any way I can achieve these routerLink-like transitions programmatically?
Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.
Activity
OoDeLally commentedon Feb 18, 2020
Similar/equal to #19984
elylucas commentedon Feb 18, 2020
This is by design. please see https://ionicframework.com/docs/react/navigation#ionrouteroutlet
OoDeLally commentedon Feb 18, 2020
Hello @elylucas
I realized that it does unmount if in addition to
routerLink="...", I userouterDirection="back", then the page is effectively unmounted.This is quite an unexpected behavior.
The doc mentions:
Each of these components also have a routerDirection prop to explicitly set the type of page transition to use ("back", "forward", or "none").It is not obvious to me that this above implies which values unmount the component or not. May I suggest to make it extremely clear? I was banging my head for several hours on that problem.
elylucas commentedon Feb 18, 2020
Yep, I will look into that.
The idea is if you are leaving a page by going back, the state of the page no longer needs to be maintained. Contrast that by navigating between tabs or going forward from a list page to a details page, you want the same scroll position, form inputs, etc.. in place, so we keep those around in the dom and show/hide them via css.
OoDeLally commentedon Feb 18, 2020
Yes, this makes sense. However the default behavior is misleading.
imho not providing
routerDirectionshould unmount the component, while a purposefulrouterDirection="forward"should keep the component.Now, a large part of my app uses programmatical redirections, with
history.replace.history.replacedoes not seem to trigger an unmount. Any way I can achieve these routerLink-like transitions programmatically?Thanks a lot
elylucas commentedon Feb 18, 2020
Ya, you can pass in the direction as a part of the state object (2nd param to
replace):OoDeLally commentedon Feb 19, 2020
@elingerojo Thank you.
It doesnt seem to work if the page is accessed via a redirection.
This doesnt work for both version of the Redirect:
or
This problem appears for version 4.11.5, 4.11.10 as well as 5.0.0.
OoDeLally commentedon Feb 24, 2020
It seems that this problem has nothing to do with redirections, but nested IonRouterOutlets.
Made a new issue for this problem #20597
ionitron-bot commentedon Mar 25, 2020
Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.