Compare commits
1 Commits
burn/69-17
...
fix/issue-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a8f2b0925f |
19
index.html
19
index.html
@@ -808,7 +808,6 @@ Sovereignty and service always.`;
|
||||
var crisisPanel = document.getElementById('crisis-panel');
|
||||
var crisisOverlay = document.getElementById('crisis-overlay');
|
||||
var overlayDismissBtn = document.getElementById('overlay-dismiss-btn');
|
||||
var overlayCallLink = document.querySelector('.overlay-call');
|
||||
var statusDot = document.querySelector('.status-dot');
|
||||
var statusText = document.getElementById('status-text');
|
||||
|
||||
@@ -1030,12 +1029,12 @@ Sovereignty and service always.`;
|
||||
overlayDismissBtn.textContent = 'Continue to chat (' + countdown + 's)';
|
||||
|
||||
// Disable background interaction via inert attribute
|
||||
var mainApp = document.querySelector('.app');
|
||||
var mainApp = document.getElementById('app');
|
||||
if (mainApp) mainApp.setAttribute('inert', '');
|
||||
// Also hide from assistive tech
|
||||
var chatSection = document.getElementById('chat');
|
||||
var chatSection = document.getElementById('chat-area');
|
||||
if (chatSection) chatSection.setAttribute('aria-hidden', 'true');
|
||||
var footerEl = document.querySelector('footer');
|
||||
var footerEl = document.getElementById('footer');
|
||||
if (footerEl) footerEl.setAttribute('aria-hidden', 'true');
|
||||
|
||||
if (overlayTimer) clearInterval(overlayTimer);
|
||||
@@ -1051,8 +1050,10 @@ Sovereignty and service always.`;
|
||||
}
|
||||
}, 1000);
|
||||
|
||||
// Focus the Call 988 link (always enabled) — disabled buttons cannot receive focus
|
||||
if (overlayCallLink) overlayCallLink.focus();
|
||||
var overlayCallLink = crisisOverlay.querySelector('.overlay-call');
|
||||
if (overlayCallLink && typeof overlayCallLink.focus === 'function') {
|
||||
overlayCallLink.focus();
|
||||
}
|
||||
}
|
||||
|
||||
// Register focus trap on document (always listening, gated by class check)
|
||||
@@ -1067,11 +1068,11 @@ Sovereignty and service always.`;
|
||||
}
|
||||
|
||||
// Re-enable background interaction
|
||||
var mainApp = document.querySelector('.app');
|
||||
var mainApp = document.getElementById('app');
|
||||
if (mainApp) mainApp.removeAttribute('inert');
|
||||
var chatSection = document.getElementById('chat');
|
||||
var chatSection = document.getElementById('chat-area');
|
||||
if (chatSection) chatSection.removeAttribute('aria-hidden');
|
||||
var footerEl = document.querySelector('footer');
|
||||
var footerEl = document.getElementById('footer');
|
||||
if (footerEl) footerEl.removeAttribute('aria-hidden');
|
||||
|
||||
// Restore focus to the element that had it before the overlay opened
|
||||
|
||||
@@ -52,34 +52,6 @@ class TestCrisisOverlayFocusTrap(unittest.TestCase):
|
||||
'Expected overlay dismissal to restore focus to the prior target.',
|
||||
)
|
||||
|
||||
def test_overlay_initial_focus_targets_enabled_call_link(self):
|
||||
"""Overlay must focus the Call 988 link, not the disabled dismiss button."""
|
||||
# Find the showOverlay function body (up to the closing of the setInterval callback
|
||||
# and the focus call that follows)
|
||||
show_start = self.html.find('function showOverlay()')
|
||||
self.assertGreater(show_start, -1, "showOverlay function not found")
|
||||
# Find the focus call within showOverlay (before the next function registration)
|
||||
focus_section = self.html[show_start:show_start + 2000]
|
||||
self.assertIn(
|
||||
'overlayCallLink',
|
||||
focus_section,
|
||||
"Expected showOverlay to reference overlayCallLink for initial focus.",
|
||||
)
|
||||
# Ensure the old buggy pattern is gone
|
||||
focus_line_region = self.html[show_start + 800:show_start + 1200]
|
||||
self.assertNotIn(
|
||||
'overlayDismissBtn.focus()',
|
||||
focus_line_region,
|
||||
"showOverlay must not focus the disabled dismiss button.",
|
||||
)
|
||||
|
||||
def test_overlay_call_link_variable_is_declared(self):
|
||||
self.assertIn(
|
||||
"querySelector('.overlay-call')",
|
||||
self.html,
|
||||
"Expected a JS reference to the .overlay-call link element.",
|
||||
)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
55
tests/test_crisis_overlay_initial_focus.py
Normal file
55
tests/test_crisis_overlay_initial_focus.py
Normal file
@@ -0,0 +1,55 @@
|
||||
import pathlib
|
||||
import re
|
||||
import unittest
|
||||
|
||||
ROOT = pathlib.Path(__file__).resolve().parents[1]
|
||||
INDEX_HTML = ROOT / 'index.html'
|
||||
|
||||
|
||||
class TestCrisisOverlayInitialFocus(unittest.TestCase):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
cls.html = INDEX_HTML.read_text()
|
||||
|
||||
def test_overlay_focuses_enabled_call_link_on_open(self):
|
||||
self.assertRegex(
|
||||
self.html,
|
||||
r"overlayCallLink\s*=\s*crisisOverlay\.querySelector\('\.overlay-call'\)",
|
||||
'Expected showOverlay() to capture the enabled 988 call link as the initial focus target.',
|
||||
)
|
||||
self.assertRegex(
|
||||
self.html,
|
||||
r"overlayCallLink\.focus\(\)",
|
||||
'Expected showOverlay() to focus the enabled 988 call link on open.',
|
||||
)
|
||||
self.assertNotRegex(
|
||||
self.html,
|
||||
r"overlayDismissBtn\.focus\(\)",
|
||||
'Initial focus should not target the disabled dismiss button.',
|
||||
)
|
||||
|
||||
def test_overlay_uses_live_dom_targets_for_background_locking(self):
|
||||
self.assertRegex(
|
||||
self.html,
|
||||
r"document\.getElementById\('app'\)",
|
||||
'Expected overlay to inert the live #app container.',
|
||||
)
|
||||
self.assertRegex(
|
||||
self.html,
|
||||
r"document\.getElementById\('chat-area'\)",
|
||||
'Expected overlay to hide the live #chat-area region from assistive tech while active.',
|
||||
)
|
||||
self.assertNotRegex(
|
||||
self.html,
|
||||
r"document\.querySelector\('\.app'\)",
|
||||
'The overlay should not target a nonexistent .app selector.',
|
||||
)
|
||||
self.assertNotRegex(
|
||||
self.html,
|
||||
r"document\.getElementById\('chat'\)",
|
||||
'The overlay should not target a nonexistent #chat region.',
|
||||
)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user