Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Step triggers "before-hide" twice on every transition #170

Closed
DennisBaekgaard opened this issue Aug 7, 2017 · 1 comment
Closed

Step triggers "before-hide" twice on every transition #170

DennisBaekgaard opened this issue Aug 7, 2017 · 1 comment

Comments

@DennisBaekgaard
Copy link

I've been playing around with Shepherd for a bit, and modified it for my own purposes (including adding some additional steps which seems odd aren't already in the source such as Tour.on("next",..) and "back" depending on if you're going forwards or backwards in the tour). Anywho, I thought it was a mistake on my part and binding the before-show event twice, but it seems that the native code fires it twice for every transition.

The issue
First off, a quick example of the behaviour can be seen here (JSFiddle) .

Mind you that the line numbers below may be one or two off because of my alterations to the library.

From what I can see, Step.hide() (L310) runs when tour.next is called - that method triggers a "before-hide" event accounting for the first one. In the bottom of this method, a new event is triggered with this.trigger('hide'); - suggesting the life-cycle of this step has completed.

hide() {
    this.trigger('before-hide');
    removeClass(this.el, 'shepherd-open');

    document.body.removeAttribute('data-shepherd-step');

    if (this.tether) {
        this.tether.destroy();
    }
    this.tether = null;

    this.trigger('hide');
}

The code now bounce to Tour.show() (L619) which eventually runs L648 this.currentStep.hide() which once again runs the above code, triggering another "before-hide" event.

Potential fix:
I tried deleting L647-649:

if (this.currentStep) {
    this.currentStep.hide();
}

and removed the extra call to hide with the assumption that the element should already have been hidden. My tests worked identically, just without the extra method call, however, I'm not sure if there's a case where the initial call to hide() is not called.

@RobbieTheWagner
Copy link
Member

I believe this is a duplicate of #167 which we have now merged in a fix for. Please try the latest beta and let me know if things work for you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants