-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Closed
Labels
Description
Description
There is a bug in _nextStep method which results in:
Cannot read property 'element' of undefined
Expected Behavior
_nextStep should not execute when right arrow is pressed while on last item in introItem set.
Actual Behavior
When one uses arrow keys to move through items, after reaching last element on the item set and pressing right arrow key produces an error, because this._currentStep exceeds the this._introItems array, resulting in call on undefined.
Errors and Screenshots (optional)
Example (recommended)
Press right arrow key while being on last item in the set of Intro js
Environment (optional)
Problem is with code logic, not the environment.
Problem can be solved by simple if check:
if (typeof (this._currentStepNumber) !== 'undefined') {
_forEach(this._introItems, function (item, i) {
if( item.step === this._currentStepNumber ) {
this._currentStep = i - 1;
this._currentStepNumber = undefined;
}
}.bind(this));
}
// added check here before _currentStep mutation
if (this._introItems.length - 1 < this._currentStep + 1) {
return;
}
if (typeof (this._currentStep) === 'undefined') {
this._currentStep = 0;
} else {
++this._currentStep;
}
vbartusevicius and vsdudakov
