Skip to content

ion-back-button does not clean window.history #17752

Closed

Description

@maumchaves

Bug Report

Ionic version:

[x] 4.4.0 Beryllium

Current behavior:

When going back with the ion-back-button, the page is not being removed from the window.history. Example:

// First page (without back button)
window.history
History {length: 1, scrollRestoration: "auto", state: {…}}

// After navigating to page with back button
window.history
History {length: 2, scrollRestoration: "auto", state: {…}}

// After clicking on back button
window.history
History {length: 3, scrollRestoration: "auto", state: {…}}

Expected behavior:

After clicking the ion-back-button, we should remove that page from window.history. This should behave exactly the same as this.ionNavCtrl.back(), which seems to work as expected. Also, if it is not possible to go back and the ion-back-button uses the defaultBackLink property, then it should replace the current page with the one specified by the defaultBackLink property so we don't keep that in window.history.

Ionic info:

Ionic:

   ionic (Ionic CLI)             : 4.11.0 (/usr/local/lib/node_modules/ionic)
   Ionic Framework               : @ionic/angular 4.4.0
   @angular-devkit/build-angular : 0.13.9
   @angular-devkit/schematics    : 7.3.9
   @angular/cli                  : 7.3.9
   @ionic/angular-toolkit        : 1.5.1

Cordova:

   cordova (Cordova CLI) : 7.0.1
   Cordova Platforms     : not available
   Cordova Plugins       : not available

System:

   Android SDK Tools : 26.1.1 (/Users/mau/Library/Android/sdk)
   ios-deploy        : 1.9.2
   ios-sim           : 6.1.2
   NodeJS            : v8.11.3 (/usr/local/bin/node)
   npm               : 6.9.0
   OS                : macOS Mojave
   Xcode             : Xcode 10.2.1 Build version 10E1001

Activity

  1. KevinKelchen commented on Mar 11, 2019

    @KevinKelchen

    Related to #15428 and #15181.

  2. juanparadox commented on Mar 23, 2019

    @juanparadox

    Possibly related to #17445 ?

  3. maumchaves commented on May 18, 2019

    @maumchaves
    Author

    I've updated my Ionic version from 4.1.1 to 4.4.0 and the problem remains. The description of this issue has been updated accordingly.

  4. StefanNedelchev commented on Mar 23, 2021

    @StefanNedelchev

    If I understand the description correctly - the issue still exists and I experienced it. When I navigate back using ion-back-button, the page still remains in the history and if I use the browser's back button afterwards I end up in the page that I have previously left. This is not the behavior that I would expect and it can create even worse problems if I use only the ion-back-button for navigation which may cause the same pages to be stacked in the history again and again.

  5. bigboy-pdb-spam commented on Dec 10, 2021

    @bigboy-pdb-spam

    I came here to report a bug about problems with the back button functionality in Ionic Core, but this issue appears to either be the same issue or strongly related. The issue can be seen in this fiddle. The suggestion to use the back functionality in the navigation controller seems to work properly (as can be seen in this fiddle). In Ionic Core, the pop function can be used to move back one page.

  6. StefanNedelchev commented on Dec 10, 2021

    @StefanNedelchev

    I guess this is the same issue? #23448

  7. bigboy-pdb-spam commented on Dec 11, 2021

    @bigboy-pdb-spam

    I believe so.

  8. averyrousseau commented on Feb 2, 2022

    @averyrousseau
    Contributor

    Thanks for the issue. I'm going to close this as a duplicate of #23448. While this issue is much older, we already have the other one tracked as a bug internally, so this seems like the best way to consolidate things.

  9. ionitron-bot commented on Mar 4, 2022

    @ionitron-bot

    Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.

  10. locked and limited conversation to collaborators on Mar 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions