Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion packages/vue/src/components/IonTabButton.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,12 @@ export const IonTabButton = /*@__PURE__*/ defineComponent({
* then we must be on a child page and
* should direct users back to the root
* of the tab.
*
* Without a router outlet, the tabs are not
* tied to the router, so the router must not
* navigate when a tab button is clicked.
*/
if (ionRouter !== null) {
if (hasRouterOutlet && ionRouter !== null) {
if (prevActiveTab === tab) {
if (originalHref !== currentHref) {
ionRouter.resetTab(tab, originalHref);
Expand Down
14 changes: 14 additions & 0 deletions packages/vue/test/base/tests/e2e/specs/tabs.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -673,6 +673,20 @@ describe('Tabs', () => {

cy.url().should('include', '/tabs-basic');
});

it('should not navigate away when clicking the selected tab after visiting tabs with a router outlet', () => {
cy.routerPush('/tabs');
cy.ionPageVisible('tab1');

cy.routerPush('/tabs-basic');
cy.url().should('include', '/tabs-basic');
cy.get('ion-tab[data-pageid=tab1]').should('be.visible');

cy.get('ion-tabs:has(> ion-tab) ion-tab-button#tab-button-tab1').click();

cy.url().should('include', '/tabs-basic');
cy.get('ion-tab[data-pageid=tab1]').should('be.visible');
});
})

describe('Swipe to Go Back', () => {
Expand Down
Loading