question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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 <ion-back-button> 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 <ion-back-button> 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 Analytics

  • State:open
  • Created 2 years ago
  • Reactions:4
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
hardmaster92commented, Jan 7, 2022

Any news on this ? It affects our app.

doesn’t seem to be fixed even in Ionic 6

1reaction
TomDemulierChevretcommented, Jan 7, 2022

Any news on this ? It affects our app.

Read more comments on GitHub >

github_iconTop Results From Across the Web

ionic 4 ion-back-button is always return to "root" page
For a temporary workaround you could use the NavController and do a (click)="navCtrl.back()" in the ion-back-button element.
Read more >
Authentication in Ionic Angular with Supabase
Learn how to build an Ionic Angular app with authentication, Row Level Security, and Magic Link auth.
Read more >
How to correctly use routing with Vue in Ionic
When clicking on an item, I want to go to a tab child route passing ... seem to be getting all the benefits...
Read more >
Ionic 4 Beta: What's New and Building a Sample App - Auth0
Angular Router: As mentioned earlier, you need to migrate your Push/Pop navigation to Angular Router navigation. You can follow the step ...
Read more >
ionic Archives - LogRocket Blog
Ionic lets developers build mobile apps with Angular, React, Vue.js, and Stencil frontend libraries. Ionic officially supports Android, iOS, and web targets ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found