fix(vue): improve handling of parameterized urls (#22360)

resolves #22359
This commit is contained in:
Liam DeBeasi
2020-10-22 11:37:17 -04:00
committed by GitHub
parent 31f9bc81d6
commit 6fad0fe428
7 changed files with 124 additions and 45 deletions

View File

@ -46,7 +46,19 @@ export const IonRouterOutlet = defineComponent({
// The base url for this router outlet
let parentOutletPath: string;
watch(matchedRouteRef, () => setupViewItem(matchedRouteRef));
watch(matchedRouteRef, (currentValue, previousValue) => {
/**
* We need to make sure that we are not re-rendering
* the same view if navigation changes in a sub-outlet.
* This is mainly for tabs when outlet 1 renders ion-tabs
* and outlet 2 renders the individual tab view. We don't
* want outlet 1 creating a new ion-tabs instance every time
* we switch tabs.
*/
if (currentValue !== previousValue) {
setupViewItem(matchedRouteRef);
}
});
const canStart = () => {
const stack = viewStacks.getViewStack(id);
@ -273,19 +285,6 @@ export const IonRouterOutlet = defineComponent({
let enteringViewItem = viewStacks.findViewItemByRouteInfo(currentRoute, id);
if (!enteringViewItem) {
/**
* If we have no existing entering item, we need
* make sure that there is no existing view according to the
* matched route rather than what is in the url bar.
* This is mainly for tabs when outlet 1 renders ion-tabs
* and outlet 2 renders the individual tab view. We don't
* want outlet 1 creating a new ion-tabs instance every time
* we switch tabs.
*/
if (viewStacks.findViewItemByMatchedRoute(matchedRouteRef.value, id)) {
return;
}
enteringViewItem = viewStacks.createViewItem(id, matchedRouteRef.value.components.default, matchedRouteRef.value, currentRoute);
viewStacks.add(enteringViewItem);
}