(el, toggleTabIndex)
| 706 | * @param {boolean} [toggleTabIndex] |
| 707 | */ |
| 708 | export const focus = (el, toggleTabIndex) => { |
| 709 | if (!el) return; |
| 710 | |
| 711 | /** |
| 712 | * Momentarily add the `tabindex` attribute to fix |
| 713 | * a bug with focus restoration in chrome |
| 714 | */ |
| 715 | toggleTabIndex && (el.tabIndex = -1); |
| 716 | |
| 717 | el.focus(); |
| 718 | |
| 719 | /** |
| 720 | * Remove the `tabindex` attribute so |
| 721 | * that the html markup is valid again |
| 722 | */ |
| 723 | toggleTabIndex && el.removeAttribute('tabindex'); |
| 724 | }; |
| 725 | |
| 726 | /** |
| 727 | * @param {HTMLDivElement} element |
no outgoing calls
no test coverage detected
searching dependent graphs…