From 84569659b060b742d46589fbeb7eebd1f75326a1 Mon Sep 17 00:00:00 2001 From: Timmy Date: Tue, 14 Apr 2026 22:07:45 -0400 Subject: [PATCH] fix: crisis overlay focuses enabled Call 988 link instead of disabled button (closes #69) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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) --- index.html | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/index.html b/index.html index 06cff1c..a943c0c 100644 --- a/index.html +++ b/index.html @@ -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)