fix(vue): tapping the active tab button now correctly resets the tab stack (#24935)

resolves #24934
This commit is contained in:
Liam DeBeasi
2022-03-14 14:44:47 -04:00
committed by GitHub
parent d46e1e8506
commit 4534c8bc0b
4 changed files with 92 additions and 13 deletions

View File

@ -47,7 +47,7 @@ export const IonTabButton = /*@__PURE__*/ defineComponent({
*/
if (prevActiveTab === tab) {
if (originalHref !== currentHref) {
ionRouter.resetTab(tab, originalHref);
ionRouter.resetTab(tab);
}
} else {
ionRouter.changeTab(tab, currentHref)

View File

@ -51,21 +51,68 @@ describe('Tabs', () => {
cy.ionPageHidden('tab1');
});
it('should return to tab root when clicking tab button', () => {
it('should return to tab root when clicking tab button after going back', () => {
cy.visit('http://localhost:8080/tabs')
cy.get('#child-one').click();
cy.ionPageVisible('tab1childone');
cy.ionPageHidden('tab1');
cy.get('#child-two').click();
cy.ionPageHidden('tab1childone');
cy.ionPageVisible('tab1childtwo');
cy.get('ion-tab-button#tab-button-tab1').click();
cy.ionPageVisible('tab1');
// TODO this page is not removed
//cy.ionPageDoesNotExist('tab1childone');
cy.ionPageDoesNotExist('tab1childone');
cy.ionPageDoesNotExist('tab1childtwo');
})
// Verifies fix for https://github.com/ionic-team/ionic-framework/issues/24934
it('should return to tab root when clicking tab button', () => {
cy.visit('http://localhost:8080/tabs')
cy.get('#child-one').click();
cy.ionPageVisible('tab1childone');
cy.ionPageHidden('tab1');
cy.get('#child-two').click();
cy.ionPageHidden('tab1childone');
cy.ionPageVisible('tab1childtwo');
cy.ionBackClick('tab1childtwo');
cy.ionPageVisible('tab1childone');
cy.ionPageDoesNotExist('tab1childtwo');
cy.get('ion-tab-button#tab-button-tab1').click();
cy.ionPageVisible('tab1');
cy.ionPageDoesNotExist('tab1chilone');
})
// Verifies fix for https://github.com/ionic-team/ionic-framework/issues/24934
it('should return to tab root after replacing history', () => {
cy.visit('http://localhost:8080/tabs')
cy.get('#child-one').click();
cy.ionPageVisible('tab1childone');
cy.ionPageHidden('tab1');
cy.get('ion-tab-button#tab-button-tab1').click();
cy.ionPageVisible('tab1');
cy.ionPageDoesNotExist('tab1chilone');
cy.get('#child-one').click();
cy.ionPageVisible('tab1childone');
cy.ionPageHidden('tab1');
cy.get('ion-tab-button#tab-button-tab1').click();
cy.ionPageVisible('tab1');
cy.ionPageDoesNotExist('tab1chilone');
})
it('should be able to create and destroy tabs', () => {
cy.visit('http://localhost:8080')