@@ -708,6 +709,7 @@
+
@@ -1151,13 +1153,16 @@
const modal = document.getElementById(id);
modal.classList.add('active');
+ // Make background content inert (unfocusable)
+ document.getElementById('mainContent').setAttribute('inert', '');
+
// Focus first focusable element in modal
const focusable = modal.querySelectorAll('button, input, select, textarea, [tabindex]:not([tabindex="-1"])');
if (focusable.length > 0) {
setTimeout(() => focusable[0].focus(), 50);
}
- // Add event listeners for focus trap and Escape
+ // Add event listener for Escape key
document.addEventListener('keydown', handleModalKeydown);
}
@@ -1166,6 +1171,9 @@
document.removeEventListener('keydown', handleModalKeydown);
activeModalId = null;
+ // Remove inert from background content
+ document.getElementById('mainContent').removeAttribute('inert');
+
// Restore focus to previously focused element
if (previouslyFocusedElement) {
previouslyFocusedElement.focus();