fix: crisis overlay focuses enabled Call 988 link instead of disabled button (closes #69)
All checks were successful
Sanity Checks / sanity-test (pull_request) Successful in 8s
Smoke Test / smoke (pull_request) Successful in 16s

The crisis overlay's showOverlay() was calling overlayDismissBtn.focus()
immediately after setting overlayDismissBtn.disabled = true. Disabled
elements cannot receive focus in browsers, so the overlay opened without
a valid keyboard focus target.

Changes:
- Focus the .overlay-call (Call 988 link) on overlay open — it's always
  enabled and the most important action for a user in crisis
- Move overlayDismissBtn.focus() to the countdown completion handler —
  the button focus now fires when it becomes enabled
- All existing tests pass (139 passed)
This commit is contained in:
Timmy
2026-04-14 22:07:45 -04:00
parent 2697b8ef75
commit 84569659b0

View File

@@ -1045,12 +1045,18 @@ Sovereignty and service always.`;
overlayTimer = null;
overlayDismissBtn.disabled = false;
overlayDismissBtn.textContent = 'Continue to chat';
overlayDismissBtn.focus();
} else {
overlayDismissBtn.textContent = 'Continue to chat (' + countdown + 's)';
}
}, 1000);
overlayDismissBtn.focus();
// Focus the Call 988 link — the dismiss button is disabled during countdown
// and disabled elements cannot receive focus. #69
var overlayCallBtn = crisisOverlay.querySelector('.overlay-call');
if (overlayCallBtn) {
overlayCallBtn.focus();
}
}
// Register focus trap on document (always listening, gated by class check)