From 8d309723aada85d41c2ecdeaf918f7bf51b6e5ee Mon Sep 17 00:00:00 2001 From: Alexander Whitestone Date: Wed, 15 Apr 2026 03:15:05 +0000 Subject: [PATCH 1/2] feat: add Escape key handler for crisis overlay Escape closes the overlay and returns focus to chat input. Respects the 10s cooldown (won't dismiss if button is disabled). Fixes #95 --- index.html | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/index.html b/index.html index 06cff1c..7891c56 100644 --- a/index.html +++ b/index.html @@ -1056,6 +1056,15 @@ Sovereignty and service always.`; // Register focus trap on document (always listening, gated by class check) document.addEventListener('keydown', trapFocusInOverlay); + // Escape key closes crisis overlay (returns focus to chat input) + document.addEventListener('keydown', function(e) { + if (e.key === 'Escape' && crisisOverlay.classList.contains('active')) { + if (!overlayDismissBtn.disabled) { + overlayDismissBtn.click(); + } + } + }); + overlayDismissBtn.addEventListener('click', function() { if (!overlayDismissBtn.disabled) { crisisOverlay.classList.remove('active'); -- 2.43.0 From d2352ed589c0d787cda3afb30cf5fca72314268b Mon Sep 17 00:00:00 2001 From: Alexander Whitestone Date: Wed, 15 Apr 2026 03:15:30 +0000 Subject: [PATCH 2/2] test: add Escape key handler test for crisis overlay --- tests/test_crisis_overlay_focus_trap.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/test_crisis_overlay_focus_trap.py b/tests/test_crisis_overlay_focus_trap.py index f657afc..d0b86d5 100644 --- a/tests/test_crisis_overlay_focus_trap.py +++ b/tests/test_crisis_overlay_focus_trap.py @@ -53,5 +53,19 @@ class TestCrisisOverlayFocusTrap(unittest.TestCase): ) + def test_overlay_escape_key_closes_overlay(self): + """Escape key closes crisis overlay and returns focus to chat input.""" + # Verify the Escape handler exists in the HTML + self.assertRegex( + self.html, + r"e\.key\s*===\s*['"]Escape['"].*crisisOverlay\.classList\.contains\('active'\)", + 'Expected Escape key handler to check for active crisis overlay.', + ) + self.assertRegex( + self.html, + r"overlayDismissBtn\.click\(\)", + 'Expected Escape key handler to trigger overlay dismiss button click.', + ) + if __name__ == '__main__': unittest.main() -- 2.43.0