@hashicorp/design-system-components
Version:
Helios Design System Components
31 lines (27 loc) • 834 B
JavaScript
import { tabbable } from 'tabbable';
/**
* Copyright IBM Corp. 2021, 2025
* SPDX-License-Identifier: MPL-2.0
*/
const onFocusTrapDeactivate = cell => {
const cellTabbableChildren = tabbable(cell);
for (const child of cellTabbableChildren) {
child.setAttribute('tabindex', '-1');
}
cell.setAttribute('tabindex', '0');
};
const updateTabbableChildren = (cell, isFocusTrapActive) => {
const cellTabbableChildren = tabbable(cell, {
displayCheck: 'none'
});
for (const child of cellTabbableChildren) {
if (child instanceof HTMLElement) {
if (!isFocusTrapActive) {
child.setAttribute('tabindex', '-1');
}
child.setAttribute('data-advanced-table-child-focusable', '');
}
}
};
export { onFocusTrapDeactivate, updateTabbableChildren };
//# sourceMappingURL=dom-management.js.map