vue-shepherd icon indicating copy to clipboard operation
vue-shepherd copied to clipboard

What is the best practice to cancel tour if user click back browser button?

Open jarooda opened this issue 3 years ago • 2 comments

I can prevent user for clicking other button component that route to outside current component using overlay.

But if user clicking back browser button, the tour is still running.

so i use navigation guard and search the classname like this

beforeRouteLeave (to, from, next) {
    const tourOverlay =  document.getElementsByClassName('shepherd-modal-is-visible')[0]
    const tourStep = document.getElementsByClassName('shepherd-enabled')[0]

    if (tourOverlay && tourStep) {
      tourOverlay.remove()
      tourStep.tourStep()
    }

    next()
}

Is there a best practice to achieve this?

jarooda avatar Apr 22 '22 08:04 jarooda

@jarooda I am not sure what you mean here. If the user clicks the back button, wouldn't the tour go away on its own?

RobbieTheWagner avatar Apr 24 '22 14:04 RobbieTheWagner

hi @rwwagner90 , I create a reproduction of my bug here https://github.com/jarooda/test-vue-shepherd

step to produce

  1. run app
  2. go to /about using link in nav Screen Shot 2022-04-25 at 04 57 02
  3. click back using browser button Screen Shot 2022-04-25 at 04 57 08

thanks

jarooda avatar Apr 24 '22 21:04 jarooda