fix: crisis overlay focuses enabled Call 988 link instead of disabled button (closes #69)
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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user