ionic-team / ionic-team/ionic-framework

bug: angular ion-back-button pushes new entry to stack instead of popping

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

描述

# Bug Report

**Ionic version:**
**5.6.9**

**Platform**
Web

Imagine that you have the following stack in the history: [**A**, **B**]. You are currently on page **B** and press a `` element.

**Current behavior:**
The back button correctly navigates to the previous page **A** but does it by adding a new entry (let's call it **C**), leaving us with the following stack: [A, B, C]. In this case **C** and **A** are the same routes. As a result, using the native back button (or browser back button) afterwards returns the user back to page **B** while naturally you would not expect it. This seriously breaks the experience when the app is installed as a PWA resulting in large history stacks with repeating routes. Android users might have hard time closing the app if they rely on the native back button

**Expected behavior:**
The back button should navigate to page **A** while removing **B** from the stack, making it impossible for the user to return back to **B** using native navigation.

**Steps to reproduce:**

1. Generate a fresh Ionic Angular project with the CLI.
2. Create additional page if necessary and put `` in its toolbar.
3. Add a button on the main page which navigates to the 2nd page using the default ionic strategy.
4. After being navigated to the 2nd page, press the `ion-back-button`.
5. After being returned back to the main page, press the browser's back button (or the native back button if you are on Android).
6. The issue should be reproduced now

**Other information:**
This issue is not new, I've been experiencing it since I started using Ionic a couple of months ago. Also i don't know if the issue exists on native Android/iOS apps because my project is just a PWA.

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

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