Repository navigation
fix(vue-router): preserve tab context when replacing nested routes - #1
Merged
bokanechase-digistorm merged 2 commits intoNov 18, 2025
Merged
Conversation
Preserve tab property and prevent history clearing when replacing routes within tabs. This ensures back button and tab switching work correctly after replacing nested views. Co-authored-by: bokanechase-digistorm <[email protected]>
Copilot
AI
changed the title
[WIP] Fix navigation bug with nested routes and tabs
fix(vue-router): preserve tab context when replacing nested routes
Nov 18, 2025
Owner
|
@copilot Question, does calling replace now mean that the route I was on previously is replaced in the history? |
Author
Yes, that's correct. When you call Before my fix:
After my fix:
Example: The key difference is that within tabs, the tab's navigation stack is now preserved, allowing the back button to work correctly (going back to |
Owner
|
This fix didn't work so has been reverted. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Issue number: resolves ionic-team#30617
What is the current behavior?
When replacing a nested route within a tab using
ionRouter.replace(), the tab navigation stack is destroyed. This breaks both the back button (no longer navigates to previous view in tab) and tab switching (shows incorrect view or fails).Reproduction:
Root cause:
ionRouter.replace()usesrouterDirection: "root", which clears all location history including tab stacks.What is the new behavior?
Tab navigation state is preserved when replacing routes within tabs.
Changes:
router.ts: Preservetabproperty from current route when replacing (line 423)locationHistory.ts: Conditionally clear history—only wipe all state for non-tab routes with "root" direction (line 17)The back button and tab switching now work correctly after replace operations within tabs.
Does this introduce a breaking change?
Other information
Added test case covering the specific scenario: navigate within tab → switch tabs → switch back → replace route.
Original prompt
This pull request was created as a result of the following prompt from Copilot chat.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.