mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-11-06 22:29:44 +08:00
fix(vue): incorrect view rendered when using router.go(-n) (#29877)
resolves #28201 This PR fixes the navigation issue related to `router.go` that was identified in issue #28201. After working on this issue I realised that @xxllxhdj has already created a PR for this in #29847. While their fix is great, I have added tests to replicate the issue, reused existing code and `undefined` will be returned in unexpected situations - which matches the existing functionality. ## What is the current behavior? If a user navigates from `/home` -> `/pageA` -> `/pageB` -> `/pageC` -> back to `/pageB` -> then `router.go(-2)` is called the URL will be updated to `/home` correctly, but the app will try to render `/pageA`. This happens for any delta < -1. ## What is the new behavior? The app will correctly render `/pageA`, which matches the URL. ## Does this introduce a breaking change? - [ ] Yes - [X] No --------- Co-authored-by: xxllxhdj <12881488+xxllxhdj@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
47ba703a57
commit
e32fbe0210
@ -239,15 +239,11 @@ export const createLocationHistory = () => {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (delta < -1) {
|
||||
return locationHistory[locationHistory.length - 1 + delta];
|
||||
} else {
|
||||
for (let i = locationHistory.length - 2; i >= 0; i--) {
|
||||
const ri = locationHistory[i];
|
||||
if (ri) {
|
||||
if (ri.pathname === routeInfo.pushedByRoute) {
|
||||
return ri;
|
||||
}
|
||||
for (let i = locationHistory.length - 2; i >= 0; i--) {
|
||||
const ri = locationHistory[i];
|
||||
if (ri) {
|
||||
if (ri.pathname === routeInfo.pushedByRoute) {
|
||||
return locationHistory[i + 1 + delta]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user