Created
June 7, 2019 06:08
-
-
Save ryanflorence/d8b61b19b4c3541a08792f9e1c7e94a6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function handleKeyDown(event) { | |
if (event.key === "Tab" && event.shiftKey) { | |
if (shiftTabbedFromElementAfterTrigger(event)) { | |
focusLastTabbableInPopover(event); | |
} else if (shiftTabbedOutOfPopover(event)) { | |
focusTriggerRef(event); | |
} else if (shiftTabbedToBrowserChrome(event)) { | |
disableTabbablesInPopover(event); | |
} | |
} else if (event.key === "Tab") { | |
if (tabbedFromTriggerToPopover(event)) { | |
focusFirstPopoverTabbable(event); | |
} else if (tabbedOutOfPopover(event)) { | |
focusTabbableAfterTrigger(event); | |
} else if (tabbedToBrowserChrome(event)) { | |
disableTabbablesInPopover(event); | |
} | |
} | |
} | |
useEffect(() => { | |
doc.addEventListener("keydown", handleKeyDown); | |
return () => doc.removeEventListener("keydown", handleKeyDown); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment