Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const _onKeyDown = (ev?: React.KeyboardEvent): void => {
if (onKeyDown) {
onKeyDown(ev);
} else if (onClick && ev && (ev.which === KeyCodes.enter || ev.which === KeyCodes.space)) {
// If onKeyDown is undefined and onClick has been passed, then replicate a Button's behavior by triggering the onClick function on
// pressing down the 'Enter' and 'Space' keys.
onClick();
ev.preventDefault();
}
};
return x => {
const keyCode = x.which;
if (keyCode === KeyCodes.space || keyCode === KeyCodes.enter) {
x.currentTarget.click();
x.preventDefault();
x.stopPropagation();
}
};
}
return (ev: React.KeyboardEvent) => {
switch (ev.which) {
case KeyCodes.enter:
case KeyCodes.space:
callback();
break;
}
};
};
!this.focusElement(getNextElement(
ev.target as HTMLElement,
(ev.target as HTMLElement).firstChild as HTMLElement,
true,
) as HTMLElement)
) {
return
}
} else {
return
}
} else if (ev.altKey) {
return
} else {
switch (ev.which) {
case KeyCodes.space:
if (this.tryInvokeClickForFocusable(ev.target as HTMLElement)) {
break
}
return
case KeyCodes.left:
if (direction !== FocusZoneDirection.vertical) {
this.preventDefaultWhenHandled(ev)
if (this.moveFocusLeft()) {
break
}
}
return
case KeyCodes.right:
if (direction !== FocusZoneDirection.vertical) {