Sha256: b7d7c5155e57a73c3873f8a383b501302d28ce1d1996cb87efafc0c34758ff32
Contents?: true
Size: 747 Bytes
Versions: 29
Compression:
Stored size: 747 Bytes
Contents
import { KEYCODES } from 'foremanReact/common/keyCodes'; const keyPressHandler = ( e, isOpen, activeItems, highlightedIndex, selectItem, userInputValue, onSearch, ) => { switch (e.keyCode) { case KEYCODES.TAB_KEY: if (isOpen && activeItems[highlightedIndex]) { selectItem(activeItems[highlightedIndex]); e.preventDefault(); } break; case KEYCODES.ENTER: if (!isOpen || !activeItems[highlightedIndex]) { onSearch(userInputValue); e.preventDefault(); } break; default: break; } }; export const getActiveItems = items => items .filter(({ disabled, type }) => !disabled && !['header', 'divider'].includes(type)) .map(({ text }) => text); export default keyPressHandler;
Version data entries
29 entries across 29 versions & 1 rubygems