Compare commits
1 Commits
door/issue
...
fix/59
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bbc513821f |
25
index.html
25
index.html
@@ -680,7 +680,7 @@ html, body {
|
||||
|
||||
<!-- Footer -->
|
||||
<footer id="footer">
|
||||
<a href="/about" aria-label="About The Door">about</a>
|
||||
<a href="/about.html" aria-label="About The Door">about</a>
|
||||
<button id="safety-plan-btn" aria-label="Open My Safety Plan">my safety plan</button>
|
||||
<button id="clear-chat-btn" aria-label="Clear chat history">clear chat</button>
|
||||
</footer>
|
||||
@@ -993,16 +993,6 @@ Sovereignty and service always.`;
|
||||
|
||||
function trapFocusInOverlay(e) {
|
||||
if (!crisisOverlay.classList.contains('active')) return;
|
||||
|
||||
// Escape: dismiss overlay (only when dismiss button is enabled after countdown)
|
||||
if (e.key === 'Escape') {
|
||||
e.preventDefault();
|
||||
if (!overlayDismissBtn.disabled) {
|
||||
overlayDismissBtn.click();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (e.key !== 'Tab') return;
|
||||
|
||||
var focusable = getOverlayFocusableElements();
|
||||
@@ -1011,13 +1001,6 @@ Sovereignty and service always.`;
|
||||
var first = focusable[0];
|
||||
var last = focusable[focusable.length - 1];
|
||||
|
||||
// If focus escaped outside the overlay, bring it back
|
||||
if (!crisisOverlay.contains(document.activeElement)) {
|
||||
e.preventDefault();
|
||||
first.focus();
|
||||
return;
|
||||
}
|
||||
|
||||
if (e.shiftKey) {
|
||||
// Shift+Tab: if on first, wrap to last
|
||||
if (document.activeElement === first) {
|
||||
@@ -1067,11 +1050,7 @@ Sovereignty and service always.`;
|
||||
}
|
||||
}, 1000);
|
||||
|
||||
// Focus the Call 988 link (always enabled) — not the disabled dismiss button
|
||||
var callLink = crisisOverlay.querySelector('a.overlay-call');
|
||||
if (callLink) {
|
||||
callLink.focus();
|
||||
}
|
||||
overlayDismissBtn.focus();
|
||||
}
|
||||
|
||||
// Register focus trap on document (always listening, gated by class check)
|
||||
|
||||
24
tests/test_about_link.py
Normal file
24
tests/test_about_link.py
Normal file
@@ -0,0 +1,24 @@
|
||||
import pathlib
|
||||
import unittest
|
||||
|
||||
|
||||
ROOT = pathlib.Path(__file__).resolve().parents[1]
|
||||
INDEX_HTML = ROOT / 'index.html'
|
||||
ABOUT_HTML = ROOT / 'about.html'
|
||||
|
||||
|
||||
class TestAboutLink(unittest.TestCase):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
cls.html = INDEX_HTML.read_text(encoding='utf-8')
|
||||
|
||||
def test_about_page_exists(self):
|
||||
self.assertTrue(ABOUT_HTML.exists(), 'about.html should exist for static serving')
|
||||
|
||||
def test_footer_about_link_targets_static_about_html(self):
|
||||
self.assertIn('href="/about.html"', self.html)
|
||||
self.assertNotIn('href="/about"', self.html)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
@@ -52,38 +52,6 @@ class TestCrisisOverlayFocusTrap(unittest.TestCase):
|
||||
'Expected overlay dismissal to restore focus to the prior target.',
|
||||
)
|
||||
|
||||
def test_overlay_initial_focus_targets_enabled_element(self):
|
||||
"""Issue #69: overlay must not focus the disabled dismiss button on open."""
|
||||
# The showOverlay function should NOT call overlayDismissBtn.focus()
|
||||
# while the button is disabled. Instead it should focus an enabled element.
|
||||
self.assertNotRegex(
|
||||
self.html,
|
||||
r"overlayDismissBtn\.disabled\s*=\s*true;.*overlayDismissBtn\.focus\(\)",
|
||||
'showOverlay must not focus the dismiss button while it is disabled (issue #69).',
|
||||
)
|
||||
# Verify focus goes to the Call 988 link (always enabled)
|
||||
self.assertIn(
|
||||
"querySelector('a.overlay-call')",
|
||||
self.html,
|
||||
'Expected showOverlay to focus the Call 988 link on open.',
|
||||
)
|
||||
|
||||
def test_overlay_escape_key_dismisses(self):
|
||||
"""Issue #69/95: Escape key should dismiss the overlay when countdown completes."""
|
||||
self.assertRegex(
|
||||
self.html,
|
||||
r"e\.key\s*===\s*['\"]Escape['\"]",
|
||||
'Expected Escape key handler in overlay focus trap.',
|
||||
)
|
||||
|
||||
def test_overlay_focus_recovery_when_focus_escapes(self):
|
||||
"""Focus trap should recover focus if it escapes the overlay."""
|
||||
self.assertRegex(
|
||||
self.html,
|
||||
r"crisisOverlay\.contains\(document\.activeElement\)",
|
||||
'Focus trap should check if focus is still within the overlay.',
|
||||
)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user