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
3 changes: 2 additions & 1 deletion packages/react-router/src/ReactRouter/IonRouter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ class IonRouterInner extends React.PureComponent<IonRouteProps, IonRouteState> {
}

const leavingUrl = leavingLocationInfo.pathname + leavingLocationInfo.search;
if (leavingUrl !== location.pathname) {
const currentUrl = location.pathname + (location.search || '');
if (leavingUrl !== currentUrl) {
if (!this.incomingRouteParams) {
if (action === 'REPLACE') {
this.incomingRouteParams = {
Expand Down
19 changes: 19 additions & 0 deletions packages/react-router/test/base/tests/e2e/specs/routing.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,25 @@ describe('Routing Tests', () => {
cy.get('div.ion-page[data-pageid=home-details-page-1] [data-testid="details-input"]').should('have.value', '1');
});

it('Details 1 with Query Params > pop a same-URL history entry, should stay on details 1', () => {
// Regression: popstate over a same-URL entry on a search-bearing route used to trigger a false POP transition.
cy.visit(`http://localhost:${port}/routing`);
cy.ionNav('ion-item', 'Details 1 with Query Params');
cy.ionPageVisible('home-details-page-1');
cy.location('search').should('eq', '?hello=there');

cy.window().then((win) => {
win.history.pushState({ marker: true }, '', win.location.href);
});

cy.go('back');

// No teleport: still on details 1, URL unchanged.
cy.ionPageVisible('home-details-page-1');
cy.location('pathname').should('eq', '/routing/tabs/home/details/1');
cy.location('search').should('eq', '?hello=there');
});

/*
Tests to add:
Test that lifecycle events fire
Expand Down
Loading