UNPKG

@workday/canvas-kit-react

Version:

The parent module that contains all Workday Canvas Kit React components

23 lines (22 loc) 941 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.useComboboxListKeyboardHandler = void 0; const common_1 = require("@workday/canvas-kit-react/common"); const collection_1 = require("@workday/canvas-kit-react/collection"); const useComboboxModel_1 = require("./useComboboxModel"); /** * `useComboboxListKeyboardHandler` handle calling keyboard events like ArrowUp and ArrowDown only when the menu is visible. */ exports.useComboboxListKeyboardHandler = (0, common_1.createElemPropsHook)(useComboboxModel_1.useComboboxModel)(model => { const isRTL = (0, common_1.useIsRTL)(); return { onKeyDown(event) { if (model.state.visibility === 'visible') { const handled = (0, collection_1.keyboardEventToCursorEvents)(event, model, isRTL); if (handled) { event.preventDefault(); } } }, }; });