/* Implement "skip to main" button */
document.querySelector('#skip-to-main').addEventListener('click', e => {
e.preventDefault();
+ e.stopPropagation(); // Block bubbling up to document-wide click handler for client-side routing
document.querySelector('main').querySelector('a')?.focus(); // Assumes first focusable element is always <a>
});
/* Set event handlers for client-side routing. */
globalThis.addEventListener('popstate', _ => showPage(location.pathname));
document.addEventListener('click', e => {
- if (e.altKey || e.ctrlKey || e.metaKey || e.shiftKey || e.target.id === 'skip-to-main') {
+ if (e.altKey || e.ctrlKey || e.metaKey || e.shiftKey) {
return; // Use default behavior if any keyboard modifier is applied to the click or it's a special link
}