Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
onKeyDown: (e: KeyboardEvent) => {
if (!inputValue) {
if (isRtl(props) && e.keyCode === KEY_CODES.RIGHT && selectedItems.length > 0) {
setFocusedItem(selectedItems[selectedItems.length - 1]);
} else if (
!isRtl(props) &&
e.keyCode === KEY_CODES.LEFT &&
selectedItems.length > 0
) {
setFocusedItem(selectedItems[selectedItems.length - 1]);
} else if (e.keyCode === KEY_CODES.BACKSPACE && selectedItems.length > 0) {
(setDownshiftState as any)({
type: REMOVE_ITEM_STATE_TYPE,
selectedItem: selectedItems[selectedItems.length - 1]
});
(e as any).nativeEvent.preventDownshiftDefault = true;
e.preventDefault();
e.stopPropagation();
}
}
},
isVisible: isFocused || inputValue || selectedItems.length === 0,