Compare commits
1 Commits
burn/123-1
...
burn/69-17
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c058701b84 |
22
index.html
22
index.html
@@ -1050,7 +1050,13 @@ Sovereignty and service always.`;
|
||||
}
|
||||
}, 1000);
|
||||
|
||||
overlayDismissBtn.focus();
|
||||
// Focus Call 988 link (enabled) instead of disabled dismiss button (#69)
|
||||
var overlayCallLink = crisisOverlay.querySelector('.overlay-call');
|
||||
if (overlayCallLink) {
|
||||
overlayCallLink.focus();
|
||||
} else {
|
||||
overlayDismissBtn.focus();
|
||||
}
|
||||
}
|
||||
|
||||
// Register focus trap on document (always listening, gated by class check)
|
||||
@@ -1184,11 +1190,25 @@ Sovereignty and service always.`;
|
||||
}
|
||||
|
||||
closeSafetyPlan.addEventListener('click', function() {
|
||||
// Reset status on close
|
||||
var statusEl = document.getElementById('sp-status');
|
||||
if (statusEl) {
|
||||
statusEl.style.display = 'none';
|
||||
statusEl.className = '';
|
||||
statusEl.textContent = '';
|
||||
}
|
||||
safetyPlanModal.classList.remove('active');
|
||||
_restoreSafetyPlanFocus();
|
||||
});
|
||||
|
||||
cancelSafetyPlan.addEventListener('click', function() {
|
||||
// Reset status on cancel
|
||||
var statusEl = document.getElementById('sp-status');
|
||||
if (statusEl) {
|
||||
statusEl.style.display = 'none';
|
||||
statusEl.className = '';
|
||||
statusEl.textContent = '';
|
||||
}
|
||||
safetyPlanModal.classList.remove('active');
|
||||
_restoreSafetyPlanFocus();
|
||||
});
|
||||
|
||||
@@ -52,6 +52,35 @@ 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: Initial focus must target an enabled element, not the disabled dismiss button."""
|
||||
# The overlay-call link should receive focus, not overlayDismissBtn while disabled
|
||||
self.assertRegex(
|
||||
self.html,
|
||||
r"overlayCallLink\.focus\(\)",
|
||||
'Expected overlay to focus the Call 988 link (enabled) on open.',
|
||||
)
|
||||
# Verify the Call 988 link is queried
|
||||
self.assertRegex(
|
||||
self.html,
|
||||
r"crisisOverlay\.querySelector\('\.overlay-call'\)",
|
||||
'Expected overlay to query for .overlay-call link.',
|
||||
)
|
||||
# Ensure we don't focus the disabled button directly anymore
|
||||
# The old pattern was: overlayDismissBtn.focus() without any enabled check
|
||||
# New pattern should NOT have bare overlayDismissBtn.focus() without prior enabled check
|
||||
lines = self.html.split('\n')
|
||||
for line in lines:
|
||||
stripped = line.strip()
|
||||
if 'overlayDismissBtn.focus()' in stripped and 'overlayCallLink' not in line:
|
||||
# Found bare overlayDismissBtn.focus() — check context
|
||||
# Allow if it's in a fallback else branch
|
||||
if 'else' not in stripped and 'overlayCallLink' not in lines[max(0, lines.index(line)-5):lines.index(line)+1].__repr__():
|
||||
self.fail(
|
||||
'Found bare overlayDismissBtn.focus() without enabled check. '
|
||||
'Issue #69: Initial focus should target an enabled element.'
|
||||
)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user