usablica / intro.js

Lightweight, user-friendly onboarding tour library
http://introjs.com
Other
22.8k stars 2.59k forks source link

goToStepNumber() not working in v6.0.0 #1770

Closed renakollmannsuhr closed 2 years ago

renakollmannsuhr commented 2 years ago

Description

goToStepNumber(num) function is not working on version 6 like it did with version 5.1. How would I go to a specific step number in version 6? Is anyone else having this issue?

Expected Behavior

Expected to start tour at the specified step number using version 6 intro.js.

Actual Behavior

Recieved error: Uncaught TypeError: introJs(...).setOptions(...).goToStepNumber(...).start is not a function)

And the tour would not start.

Example (recommended)

In a test app using intro.js version 5.1 I was able to initiate a tour with: introJs().setOptions({ steps:[ .....]}).goToStepNumber(num).start();

I also added the data-step='' attributes to the specified elements.

However the same code in version 6 resulted in an error.

mattbarrry commented 2 years ago

I ran into the same issue. I was able to get it working by instead doing this:

let intro = introJs.setOptions({ steps: [...] });
intro.start();
intro.goToStepNumber(num);

Hope that helps.

renakollmannsuhr commented 2 years ago

@iubkud That workaround does it for me. Thanks!

afshinm commented 2 years ago

This is expected and is because goToStepNumber is an async function now, which doesn't return an IntroJS object and instead, it returns Promise<IntroJS>. See https://github.com/usablica/intro.js/blob/master/src/index.js#L207-L211

banagale commented 1 year ago

I also had this problem. I've opened a PR on the docs to address this.