Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
handleKeyDown = (e) => {
let newIndex;
const modifier = (!this.props.arrowKeysAutoSwitchTabs) ? this.focusIndex : this.aktivIndex ;
const keyCode = e.keyCode || e.which;
switch (keyCode) {
case keyCodes.right:
newIndex = (modifier < (this.getNumTabs() - 1)) ? modifier + 1 : 0 ;
break;
case keyCodes.left:
newIndex = (modifier > 0) ? modifier - 1 : this.getNumTabs() - 1 ;
break;
}
if (newIndex === undefined) return;
if (!this.props.arrowKeysAutoSwitchTabs) {
this.linkRefs[newIndex].focus();
} else {
if (typeof this.props.onChange === 'function') this.props.onChange(e, newIndex);
}
}