chore(): sync with main

This commit is contained in:
Liam DeBeasi
2021-10-22 15:24:34 -04:00
92 changed files with 66506 additions and 19097 deletions

View File

@ -202,7 +202,7 @@ export const IonRouterOutlet = /*@__PURE__*/ defineComponent({
const handlePageTransition = async () => {
const routeInfo = ionRouter.getCurrentRouteInfo();
const { routerDirection, routerAction, routerAnimation, prevRouteLastPathname } = routeInfo;
const { routerDirection, routerAction, routerAnimation, prevRouteLastPathname, delta } = routeInfo;
const enteringViewItem = viewStacks.findViewItemByRouteInfo(routeInfo, id);
let leavingViewItem = viewStacks.findLeavingViewItemByRouteInfo(routeInfo, id);
@ -274,10 +274,10 @@ See https://ionicframework.com/docs/vue/navigation#ionpage for more information.
leavingViewItem.mount = false;
leavingViewItem.ionPageElement = undefined;
leavingViewItem.ionRoute = false;
viewStacks.unmountLeavingViews(id, enteringViewItem, leavingViewItem);
viewStacks.unmountLeavingViews(id, enteringViewItem, delta);
}
} else {
viewStacks.mountIntermediaryViews(id, enteringViewItem, leavingViewItem);
viewStacks.mountIntermediaryViews(id, leavingViewItem, delta);
}
fireLifecycle(leavingViewItem.vueComponent, leavingViewItem.vueComponentRef, LIFECYCLE_DID_LEAVE);

View File

@ -334,6 +334,51 @@ describe('Routing', () => {
cy.ionPageDoesNotExist('routing');
cy.ionPageDoesNotExist('routingparameter-abc');
})
// Verifies fix for https://github.com/ionic-team/ionic-framework/issues/23987
it('should choose correct view when navigating back', () => {
cy.visit('http://localhost:8080');
cy.routerPush('/routing');
cy.ionPageVisible('routing');
cy.ionPageHidden('home');
cy.routerPush('/routing/123/view');
cy.ionPageVisible('routingparameterview');
cy.ionPageHidden('routing');
cy.routerPush('/routing/child');
cy.ionPageVisible('routingchild');
cy.ionPageHidden('routing');
cy.ionBackClick('routingchild');
cy.ionPageVisible('routingparameterview');
cy.ionPageDoesNotExist('routingchild');
cy.ionBackClick('routingparameterview');
cy.ionPageVisible('routing');
cy.ionPageDoesNotExist('routingparameterview');
cy.ionBackClick('routing');
cy.ionPageVisible('home');
cy.ionPageDoesNotExist('routing');
cy.routerPush('/routing');
cy.ionPageVisible('routing');
cy.ionPageHidden('home');
cy.routerPush('/routing/456/view');
cy.ionPageVisible('routingparameterview');
cy.ionPageHidden('routing');
cy.routerPush('/routing/child');
cy.ionPageVisible('routingchild');
cy.ionPageHidden('routing');
cy.ionBackClick('routingchild');
cy.ionPageVisible('routingparameterview');
cy.ionPageDoesNotExist('routingchild');
})
});
describe('Routing - Swipe to Go Back', () => {

View File

@ -450,4 +450,104 @@ describe('Routing', () => {
expect(beforeRouteEnterSpy).toHaveBeenCalledTimes(2);
});
it('should not mount intermediary components when delta is 1', async () => {
const Page = {
components: { IonPage },
template: `<ion-page></ion-page>`
}
const Page2 = {
components: { IonPage },
template: `<ion-page></ion-page>`
}
const Page3 = {
components: { IonPage },
template: `<ion-page></ion-page>`
}
const router = createRouter({
history: createWebHistory(process.env.BASE_URL),
routes: [
{ path: '/page', component: Page },
{ path: '/page2', component: Page2 },
{ path: '/page3', component: Page3 },
{ path: '/', redirect: '/page' }
]
});
router.push('/');
await router.isReady();
const wrapper = mount(App, {
global: {
plugins: [router, IonicVue]
}
});
expect(wrapper.findComponent(Page).exists()).toBe(true);
router.push('/page2');
await waitForRouter();
expect(wrapper.findComponent(Page2).exists()).toBe(true);
router.back();
await waitForRouter();
expect(wrapper.findComponent(Page2).exists()).toBe(false);
router.push('/page3');
await waitForRouter();
expect(wrapper.findComponent(Page2).exists()).toBe(false);
expect(wrapper.findComponent(Page3).exists()).toBe(true);
});
it('should unmount intermediary components when using router.go', async () => {
const Page = {
components: { IonPage },
template: `<ion-page></ion-page>`
}
const Page2 = {
components: { IonPage },
template: `<ion-page></ion-page>`
}
const Page3 = {
components: { IonPage },
template: `<ion-page></ion-page>`
}
const router = createRouter({
history: createWebHistory(process.env.BASE_URL),
routes: [
{ path: '/page', component: Page },
{ path: '/page2', component: Page2 },
{ path: '/page3', component: Page3 },
{ path: '/', redirect: '/page' }
]
});
router.push('/');
await router.isReady();
const wrapper = mount(App, {
global: {
plugins: [router, IonicVue]
}
});
router.push('/page2');
await waitForRouter();
router.push('/page3');
await waitForRouter();
expect(wrapper.findComponent(Page2).exists()).toBe(true);
expect(wrapper.findComponent(Page3).exists()).toBe(true);
router.go(-2);
await waitForRouter();
expect(wrapper.findComponent(Page).exists()).toBe(true);
expect(wrapper.findComponent(Page2).exists()).toBe(false);
expect(wrapper.findComponent(Page3).exists()).toBe(false);
});
});