What fresh hell is THIS now? - Patrick Lauke
The APG states that the Alert must have a aria-labelledby referencing the alert title
do you mean dialog or alertdialiog?
var focusableElements = dialogNode.querySelectorAll(':matches(input:not([disabled]), button:not([disabled]), a[href]), [tabindex="-1"], [tabindex="0"]');
href
-attribute, and elements that have a tabindex
of either '-1' or '0'. Not sure about speed impact of this.
function manageFocus(event) { var target = event.target; var key = event.keyCode; var insideDialog = alertDialog.contains(target); // Only fire if focused element is not inside the dialog if(!insideDialog) { if(event.shiftKey && key === 9) { // When shift + tab is pressed, // set focus on last focusable element inside dialog focusableElements[focusableElements.length - 1].focus(); } else if (key === 9) { // If tab is pressed, // set focus on first focusable element inside dialog focusableElements[0].focus(); } } }
document.addEventListener('keyup', manageFocus);
display: none
doesn't work in animations 🙈