Skip to content

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

Description

@jarooda

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?

Activity

  1. changed the title [-]How to cancel tour if user click back browser button?[/-] [+]What is the best practice to cancel tour if user click back browser button?[/+] on Apr 22, 2022
  2. RobbieTheWagner commented on Apr 24, 2022

    @RobbieTheWagner
    Member

    @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?

  3. jarooda commented on Apr 24, 2022

    @jarooda
    Author

    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

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

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions