Skip to content

Commit

Permalink
Update the tour index if the first step's target doesn't exist
Browse files Browse the repository at this point in the history
Closes #585
  • Loading branch information
gilbarbara committed Dec 11, 2020
1 parent 85b3e9d commit 2e9cfe8
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/components/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ class Joyride extends React.Component {

const stepsChanged = !isEqual(prevSteps, steps);
const stepIndexChanged = is.number(stepIndex) && changedProps('stepIndex');
const target = getElement(step?.target);

if (stepsChanged) {
if (validateSteps(steps, debug)) {
Expand Down Expand Up @@ -144,6 +145,16 @@ class Joyride extends React.Component {
}
}

// Update the index if the first step is not found
if (!controlled && status === STATUS.RUNNING && index === 0 && !target) {
this.store.update({ index: index + 1 });
this.callback({
...this.state,
type: EVENTS.TARGET_NOT_FOUND,
step,
});
}

const callbackData = {
...this.state,
index,
Expand Down

0 comments on commit 2e9cfe8

Please sign in to comment.