ionic-team / ionic-team/ionic-framework

bug: ion-back-button picks wrong route

未关闭
#19,030 13 条评论 4 个 reaction 已指派 0 人 在 GitHub 查看
package: core type: bug
主要语言
TypeScript
星标
52.7k
派生
13.3k
平均合并
1 天 15 小时
30 天内合并 PR
51

描述

# Bug Report

**Ionic version:**
[x] **4.x**
[x] **5.x**

**Current behavior:**
I have multiple routes that load the same component with different route props. When clicking the `ion-back-button`, it goes to a different route for the same component, dropping its route props.

**Expected behavior:**
When clicking the `ion-back-button`, it should have the same behavior as using the browser's back button and go back to the url of the previous history entry.

**Steps to reproduce/Related code:**
I created a minimal reproduction of this issue on https://github.com/simonhaenisch/ionic-nav-bug, which has been deployed to [ionic-nav-bug.vercel.app](https://ionic-nav-bug.vercel.app).

The router looks like this:

```tsx




```

To reproduce, do the following:

1. Go to Ionic's profile page (`/profile/ionic`).
2. Go to About page (`/about`).
3. Click the `ion-back-button` (not the browser's back button).

_Expected:_ Goes back to `/profile/ionic` route and shows Ionic's profile.
_Actual:_ It shows Ionic's profile, but the route changes to `/profile` (drops the "name" route prop).

**Other information:**
In this case, using the browser's back button instead works as expected, because unlike `nav.pop` it uses the browser's history stack to go back to the previous url. So I guess a work-around for me would be to implement my own back button that simply calls `window.history.back()`.

Sounds like it could (maybe) be related: #18569.

贡献指南

打开贡献指南

调研方向

Start with the ion-back-button and ion-router behavior in the linked minimal reproduction, following the navigation from /profile/ionic to /about and back. Compare nav.pop with window.history.back(); done means the back button returns to the previous history URL, /profile/ionic, without dropping the name route prop.

由索引模型根据 Issue 内容生成。

评估

技术栈
typescript
领域
frontend
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
描述清楚
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。