Skip to content

bug: routing breaks after specific sequence of navigations and clicking on ion-back-button #23873

Closed

Description

@luxterful

Prequisites

Ionic Framework Version

  • v4.x
  • v5.x
  • v6.x

Current Behavior

After following a specific order of navigation steps the ion-back-button changes the path but the back animation does not happen and the view stays the same.

Expected Behavior

The ion-back-button should trigger the animation and change the view

Steps to Reproduce

Create a blank ionic vue project and create 3 views.

Add those Views to the router and redirect root to view 2

The views have buttons to go to the next view
View 1 -> View 2 -> View 3

The views also have an ion-back-button.

The App starts on view 2

  1. go to view 3
  2. go back
  3. go back
  4. go to view 2
  5. go to view 3
  6. go back
  7. go back

Now the URL shows the path to view 1 but the last animation did not happen and we are still on view 2

ezgif com-gif-maker

Code Reproduction URL

https://github.com/luxterful/ionic-back-routing-issue

Ionic Info

Ionic:

Ionic CLI : 6.16.3 (/home/lukas/.nvm/versions/node/v14.16.1/lib/node_modules/@ionic/cli)
Ionic Framework : @ionic/vue 5.7.0

Capacitor:

Capacitor CLI : 3.2.2
@capacitor/android : not installed
@capacitor/core : 3.2.2
@capacitor/ios : not installed

Utility:

cordova-res : 0.15.3
native-run : 1.4.1

System:

NodeJS : v14.16.1 (/home/lukas/.nvm/versions/node/v14.16.1/bin/node)
npm : 7.11.2
OS : Linux 5.8

Additional Information

No response

Activity

  1. added
    package: vue
    type: bug
    on Sep 3, 2021
  2. stevearagonsite commented on Oct 15, 2021

    @stevearagonsite

    I have the same issue and try many ways to force update but doesn't execute, the event router end trigger without any error.

  3. tigohenryschultz commented on Nov 3, 2021

    @tigohenryschultz
    Contributor

    I'm running into the issue, quite a big bug in my opinion. I can't seem to figure out what causes it/reliably reproduce it.

    I am on 5.8.5 too

  4. obnijnil commented on Nov 13, 2021

    @obnijnil

    Having the same issue, and it's happening occasionally, including not going back when clicking the ion-back-button and not going forward when calling Vue router's router.replace().
    Have to kill the app or reload the url in the browser to make it navigate properly.

    I'm using @ionic/vue 5.8.5, vue 3.2.21 and vue-router 4.0.12.

  5. scottix commented on Nov 18, 2021

    @scottix

    We are on 5.9.1 and running into an issue that sounds very similar to this, that is getting stuck on a page randomly when navigating in the app.

    It is causing a blocker in our deployment, any idea of a fix?

  6. RobinHavre commented on Nov 25, 2021

    @RobinHavre

    We are experiencing the same issue, and for us it's been a pain through all of 5.x and now also on all the RC's for Ionic 6

  7. RobinHavre commented on Nov 25, 2021

    @RobinHavre

    As said this bug (or something very similar) has been a pain for us both in v5.x and in v6 RC 0 through 3.

    The most important observation is that this bug is only produced when we are navigating using ion-back-button or using router-link together with router-direction="root".

    We have found three workarounds, both of which prevents the bug from happening, but each having their own caveats.

    1. Override the default ion-back-button-behavior.
    This resolves the ion-back-button from triggering the bug (but does nothing for router-link).
    Example:

    <ion-back-button :default-href="defaultHref" @click.prevent="navigateBack()"></ion-back-button>
    function navigateBack() {
      router.go(-1);
    }

    2. Use MemoryHistory instead of WebHistory
    This seems to resolve both bugs with the navigation breaking, but we would really like to keep using WebHistory.

    const router = createRouter({
      // history: createWebHistory(process.env.BASE_URL),
      history: createMemoryHistory(process.env.BASE_URL),
      routes
    })

    3. Use WebHashHistory instead of WebHistory
    This seems to resolve the bugs with router-link, but does not help with <ion-back-button>

    const router = createRouter({
      // history: createWebHistory(process.env.BASE_URL),
      history: createWebHashHistory(process.env.BASE_URL),
      routes
    })

    These are hacks we are using temporarily, while waiting for the issue to be resolved.

  8. maelp commented on Dec 24, 2021

    @maelp

    I have the same issue with VueJS, it seems that createMemoryHistory solves it, but then the back button in the browser no longer works, and createWebHashHistory does not seem to fix the bug

  9. maelp commented on Dec 24, 2021

    @maelp

    As a reference I rewrote my VueJS app to use a single ion-router-outlet, and still this happens. There is sometimes a bug with a missing element (undefined) that Ionic tries to set classList to, and then the router stops working (leavingEl is because leavingViewItem.ionPageElement is undefined)

    image

  10. tigohenryschultz commented on Dec 24, 2021

    @tigohenryschultz
    Contributor

    As a reference I rewrote my VueJS app to use a single ion-router-outlet, and still this happens. There is sometimes a bug with a missing element (undefined) that Ionic tries to set classList to, and then the router stops working (leavingEl is because leavingViewItem.ionPageElement is undefined)

    image

    This seems like something I fixed in this pull request: #24433
    The tabs using another ion-router-outlet seems funky but I was able to have them play nicely.

  11. maelp commented on Dec 28, 2021

    @maelp

    Seems the bug was for another reason and I fixed it :)

  12. Cannonb4ll commented on Jan 20, 2022

    @Cannonb4ll

    @maelp

    What was the fix you've used?

  13. 6 remaining items

  14. liamdebeasi commented on Jan 27, 2022

    @liamdebeasi
    Contributor

    Hi there,

    Can everyone try the following dev build and let me know if it resolves the issue?

    npm install @ionic/[email protected] @ionic/[email protected]
    

    I tested this dev build on the app in #23873 (comment) and verified that the issue no longer reproduces. (Though additional testing is always appreciated 😄 )


    For some added context, this issue happens when using default-href on ion-back-button to go back to a page that had previously not existed. If you are not using default-href but running into the same behavior as described in this thread, please create a new issue. The issue you are running into is related to a different problem and needs to be triaged separately.

    For anyone interested in why this problem was happening, please see the comment I added in the related PR: https://github.com/ionic-team/ionic-framework/pull/24670/files

  15. migo315 commented on Jan 27, 2022

    @migo315

    Thanks for the fix. I will test it this weekend. :-)

  16. alons182 commented on Jan 28, 2022

    @alons182

    Hi @liamdebeasi
    I tried it and it seems that the error is fixed... but in an application that uses sidemenu the error reappears when I click on a menu item and then navigate through the buttons. I don't know if it is related to the same issues
    I leave you some examples

    from Home Page (menu item)
    ezgif com-gif-maker

    from List Page (No menu Item)
    ezgif com-gif-maker2

  17. liamdebeasi commented on Jan 28, 2022

    @liamdebeasi
    Contributor

    Do you have a GitHub repo I can take a look at?

  18. alons182 commented on Jan 28, 2022

    @alons182
  19. Cannonb4ll commented on Jan 28, 2022

    @Cannonb4ll

    @liamdebeasi I have tested this in my app with a side menu as well, I don't get the same error @alons182 has with a side menu. I will do some more testing to see whether it comes back.

    What I did in the side menu by the way was replace:

    router-direction="root" :router-link="p.url"
    

    With:

    @click="$router.replace(p.url)"
    
  20. liamdebeasi commented on Jan 31, 2022

    @liamdebeasi
    Contributor

    Thanks for testing! I resolved those issues and added a new dev build to #23873 (comment).

    Mind giving it another test?

    npm install @ionic/[email protected] @ionic/[email protected]
    
  21. Cannonb4ll commented on Jan 31, 2022

    @Cannonb4ll

    Just did a thoroughly test and it seems completely resolved for me now.

  22. alons182 commented on Jan 31, 2022

    @alons182

    Everything seems to be working fine now

  23. jreviews commented on Jan 31, 2022

    @jreviews

    Just tested as well and I am no longer getting the error. Many thanks for your efforts @liamdebeasi

  24. added a commit that references this issue on Feb 2, 2022
    0b18260
  25. liamdebeasi commented on Feb 2, 2022

    @liamdebeasi
    Contributor

    Thanks for the issue. This has been resolved via #24670, and a fix will be available in an upcoming release of Ionic Framework.

    Thank you very much to everyone who helped test and provide feedback! We appreciate your patience as we worked to resolve this issue.

  26. 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.

  27. 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

    package: vuetype: bug

    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