UNPKG

@workday/canvas-kit-react

Version:

The parent module that contains all Workday Canvas Kit React components

24 lines (23 loc) 1.14 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.useModalHeading = void 0; const common_1 = require("@workday/canvas-kit-react/common"); const popup_1 = require("@workday/canvas-kit-react/popup"); exports.useModalHeading = (0, common_1.composeHooks)(popup_1.usePopupHeading, (0, common_1.createElemPropsHook)(popup_1.usePopupModel)((_, ref) => { const { elementRef, localRef } = (0, common_1.useLocalRef)(ref); (0, common_1.useMountLayout)(() => { var _a, _b, _c; if ((_c = (_b = (_a = localRef.current) === null || _a === void 0 ? void 0 : _a.parentElement) === null || _b === void 0 ? void 0 : _b.querySelector('button')) === null || _c === void 0 ? void 0 : _c.textContent) { // First button is not a close icon button, set tabindex on the heading to capture initial focus localRef.current.setAttribute('tabindex', '0'); } }); const onBlur = () => { var _a; (_a = localRef.current) === null || _a === void 0 ? void 0 : _a.removeAttribute('tabindex'); }; return { ref: elementRef, onBlur, }; }));