MCPcopy
hub / github.com/orestbida/cookieconsent / focus

Function focus

src/utils/general.js:708–724  ·  view source on GitHub ↗
(el, toggleTabIndex)

Source from the content-addressed store, hash-verified

706 * @param {boolean} [toggleTabIndex]
707 */
708export 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

Callers 6

showFunction · 0.90
hideFunction · 0.90
showPreferencesFunction · 0.90
hidePreferencesFunction · 0.90
setFocusFunction · 0.85
trapFocusFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…