fix(vue): replacing routes across nested outlets preserves previous route info #25171
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Pull request checklist
Please check if your PR fulfills the following requirements:
npm run build
) was run locally and any changes were pushednpm run lint
) has passed locally and any fixes were made for failuresPull request type
Please check the type of change your PR introduces:
What is the current behavior?
Issue URL: resolves #25017
When going across nested outlets, we were accidentally wiping the previous route. Given the following scenario:
/top-level-outlet
-->/nested-outlet/1
--> (replace)/nested-outlet/2
.When replacing to
/nested-outlet/2
we first removed location history starting with/nested-outlet/1
(because it is getting replaced): https://github.com/ionic-team/ionic-framework/blob/main/packages/vue-router/src/router.ts#L374This is the correct behavior.
However, the routerAction is
replace
here which means thatlocationHistory.add
also performed another replace operation: https://github.com/ionic-team/ionic-framework/blob/main/packages/vue-router/src/locationHistory.ts#L9-L11This means that the
/top-level-outlet
info was wiped before/nested-outlet/2
was added. Since/top-level-outlet
was wiped, pressing theion-back-button
in the nested outlet component would not go back to/top-level-outlet
.What is the new behavior?
should show first page
test is made redundant by thebeforeEach
hook innested.js
, so I removed it.ionPageVisible('nestedchild')
call inshould go navigate across nested outlet contexts
. This check is already done in thebeforeEach
hook.Does this introduce a breaking change?
Other information
We can likely clean up this behavior even further. The logic I removed dates back pretty far in Ionic React: #21693 I'm not really sure it's even needed anymore.
Dev build: 6.1.3-dev.11650490791.156717e3