sjmc11 / tourguide-js

TourGuide is a Javascript library for creating user tours and on-boarding steps for your apps.
https://tourguidejs.com
MIT License
592 stars 27 forks source link

`handleFinishTour()` does not exit tour if 'tg_tours_complete' is not set in localStorage #9

Closed mjgwood closed 1 year ago

mjgwood commented 1 year ago

I noticed that I have to click the 'Finish' button twice to close the tour modal if 'tg_tours_complete' isn't set yet, but only once if it is.

Am I correct in thinking that exit() should be called before the first return statement here?

if(this.options.completeOnFinish) {
    if (!localStorage.tg_tours_complete) {
        localStorage.tg_tours_complete = [tourGroup]
        return
    }
    const storageTours = (localStorage.tg_tours_complete as string).split(',')
    storageTours.push(tourGroup)
    localStorage.tg_tours_complete = storageTours
}
if(exit) await this.exit()
this.activeStep = 0
return true
sjmc11 commented 1 year ago

Thanks for the PR. Tested and merged.