Skip to content

Commit 1c93b75

Browse files
authoredMar 22, 2021
fix(react): correctly show ion-back-button when going back (#23069)
resolves #22692
1 parent b04fb6e commit 1c93b75

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed
 

‎packages/react-router/src/ReactRouter/StackManager.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ export class StackManager extends React.PureComponent<StackManagerProps, StackMa
194194
deepWait: true,
195195
duration: direction === undefined ? 0 : undefined,
196196
direction: direction as any,
197-
showGoBack: direction === 'forward',
197+
showGoBack: !!routeInfo.pushedByRoute,
198198
progressAnimation: false,
199199
animationBuilder: routeInfo.routeAnimation,
200200
});

‎packages/react-router/test-app/cypress/integration/routing.spec.js

+21
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,27 @@ describe('Routing Tests', () => {
289289
cy.ionPageVisible('home-page');
290290
cy.ionPageHidden('favorites-page');
291291
});
292+
293+
it('should show back button when going back to a pushed page', () => {
294+
cy.visit(`http://localhost:${port}/routing/tabs/home`);
295+
296+
cy.ionNav('ion-item', 'Details 1');
297+
cy.ionPageHidden('home-page');
298+
cy.ionPageVisible('home-details-page-1');
299+
300+
cy.get('ion-tab-button#tab-button-settings').click();
301+
cy.ionPageHidden('home-details-page-1');
302+
cy.ionPageVisible('settings-page');
303+
304+
cy.get('ion-tab-button#tab-button-home').click();
305+
cy.ionPageHidden('settings-page');
306+
cy.ionPageVisible('home-details-page-1');
307+
308+
cy.ionBackClick('home-details-page-1');
309+
310+
cy.ionPageDoesNotExist('home-details-page-1');
311+
cy.ionPageVisible('home-page');
312+
});
292313
/*
293314
Tests to add:
294315
Test that lifecycle events fire

‎packages/react-router/test-app/src/pages/routing/Details.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ const Details: React.FC<DetailsProps> = () => {
3737
<IonHeader>
3838
<IonToolbar>
3939
<IonButtons>
40-
<IonBackButton defaultHref="/routing/tabs/home"></IonBackButton>
40+
<IonBackButton></IonBackButton>
4141
</IonButtons>
4242
<IonTitle>Details</IonTitle>
4343
</IonToolbar>

0 commit comments

Comments
 (0)
Please sign in to comment.