GlobalHive / vuejs-tour

VueJS Tour is a lightweight, simple and customizable tour plugin. It provides a quick and easy way to guide your users through your application.
https://globalhive.github.io/vuejs-tour/
MIT License
84 stars 7 forks source link

OnBefore Promise Bug #73

Closed michaelpelletier closed 1 month ago

michaelpelletier commented 1 month ago

There is an order-of-operations bug with using Promises in an onBefore

Screenshot 2024-10-18 at 4 15 35 PM

OnBefore is called within updatePosition which means if you're trying to do something involved in delaying it, the text has already updated to the next step before your onBefore even fires, putting you into an awkward non-state.

My use case is that for the tour I am changing pages, so I need to fire a router push in between steps. As written now, this code will move me on to the next step before the page changes.

The easy solution is to move the updatePosition call to be earlier, but I think that runs into the problem then that updatePosition also calls the onAfter which would then likely be out of sync in the same (inverted) way.

I'll open a PR in a little bit but my proposed solution is to split this up into multiple calls, essentially:

GlobalHive commented 1 month ago

Hey @michaelpelletier Thanks for this issue.

I will check your PR today evening as soon as im at home.

Best Regards, Sascha

GlobalHive commented 1 month ago

Very well done! I merged your PR, and updated the package everywhere. #75

Best Regards, Sascha