bug: vue, react, ion-back-button does not always select correct route when going back

Bug Report

Ionic version:

[ ] 4.x
[x] 5.x

Current behavior:
The back button behavior works for most straightforward cases, but depending upon the sequence of the history, sometimes the route gets replaced instead of the router.back() getting called.

Expected behavior:
router should go back() if an the available history entry is applicable.

Steps to reproduce:
clone and run test application, follow replication steps:

run ionic serve

  1. visit root at localhost:8100
  • You should be redirected to /A
  • The back button at the top of the page is set to be disabled if the $route.fullPath === history.state.back. (If you’re navigating from page to page and never visiting the same page in a row, then we should expect the current path and the next back path to never be the same)
  1. Use the Page buttons to navigate through the following sequence (not limited to this sequence)
  • Page B, Page C, Page B, Page A, Page B, Page C
  1. Press Back Button
  2. Route Should be /B and back button should be enabled
  3. Press Back Button

Expected

  • Route should be /A and back button should be enabled

Actual

  • Route is /A, but back button is disabled

Related

Ionic Back Button Issue with explanation: https://github.com/sheamusburns/issue-ionic-router-back-button
Related Form Post: https://forum.ionicframework.com/t/vue-router-history-not-updating-history-state-back-after-ion-back-button-default-click-event/203468

Other information:
N/A

Ionic info:

Ionic:

   Ionic CLI       : 6.12.3 (/Users/sheamusburns/.nvm/versions/node/v12.16.0/lib/node_modules/@ionic/cli)
   Ionic Framework : @ionic/vue 5.5.2

Capacitor:

   Capacitor CLI   : 2.4.6
   @capacitor/core : 2.4.6

Utility:

   cordova-res : 0.15.2
   native-run  : not installed

System:

   NodeJS : v12.16.0 (/Users/sheamusburns/.nvm/versions/node/v12.16.0/bin/node)
   npm    : 6.14.11
   OS     : macOS Big Sur

1 possible answer(s) on “bug: vue, react, ion-back-button does not always select correct route when going back