fix(react): correctly show ion-back-button when going back (#23069)

resolves #22692
This commit is contained in:
Liam DeBeasi
2021-03-22 16:11:45 -04:00
committed by GitHub
parent b04fb6e849
commit 1c93b75e39
3 changed files with 23 additions and 2 deletions

View File

@ -194,7 +194,7 @@ export class StackManager extends React.PureComponent<StackManagerProps, StackMa
deepWait: true, deepWait: true,
duration: direction === undefined ? 0 : undefined, duration: direction === undefined ? 0 : undefined,
direction: direction as any, direction: direction as any,
showGoBack: direction === 'forward', showGoBack: !!routeInfo.pushedByRoute,
progressAnimation: false, progressAnimation: false,
animationBuilder: routeInfo.routeAnimation, animationBuilder: routeInfo.routeAnimation,
}); });

View File

@ -289,6 +289,27 @@ describe('Routing Tests', () => {
cy.ionPageVisible('home-page'); cy.ionPageVisible('home-page');
cy.ionPageHidden('favorites-page'); cy.ionPageHidden('favorites-page');
}); });
it('should show back button when going back to a pushed page', () => {
cy.visit(`http://localhost:${port}/routing/tabs/home`);
cy.ionNav('ion-item', 'Details 1');
cy.ionPageHidden('home-page');
cy.ionPageVisible('home-details-page-1');
cy.get('ion-tab-button#tab-button-settings').click();
cy.ionPageHidden('home-details-page-1');
cy.ionPageVisible('settings-page');
cy.get('ion-tab-button#tab-button-home').click();
cy.ionPageHidden('settings-page');
cy.ionPageVisible('home-details-page-1');
cy.ionBackClick('home-details-page-1');
cy.ionPageDoesNotExist('home-details-page-1');
cy.ionPageVisible('home-page');
});
/* /*
Tests to add: Tests to add:
Test that lifecycle events fire Test that lifecycle events fire

View File

@ -37,7 +37,7 @@ const Details: React.FC<DetailsProps> = () => {
<IonHeader> <IonHeader>
<IonToolbar> <IonToolbar>
<IonButtons> <IonButtons>
<IonBackButton defaultHref="/routing/tabs/home"></IonBackButton> <IonBackButton></IonBackButton>
</IonButtons> </IonButtons>
<IonTitle>Details</IonTitle> <IonTitle>Details</IonTitle>
</IonToolbar> </IonToolbar>