focus: restore body focus on overlay close, test shield, ESC closes results

Focus restoration:
* editor.js closeModal(): blur activeElement after the close so board
  shortcuts (arrows, bare keys) work immediately without clicking.
* detail.js closeDetail(): same blur, skipped when openedFromSearch
  (search input should keep focus in that case).
* search.js closeSearch(): blur after removing .open.
* calendar.js closeCalendar(): blur after closeDayPopup.
All four check activeElement !== body before blurring to avoid no-ops.

Test shield (loader.js):
* ensureProgressBar() now also creates #test-shield — a transparent
  fixed overlay (z-index one below the progress bar) covering the
  viewport below the bar. Blocks all real mouse interaction while
  tests run; synthetic events from the test suite still work because
  they bypass pointer-events. cursor:not-allowed as visual feedback.
  Removed by hideProgress() alongside the progress bar.

ESC closes test results (runner.js):
* The existing keydown listener now also handles Escape when the
  test-panel is visible. stopPropagation prevents the app's Escape
  chain from firing a second close underneath.

Tests (board.test.js):
* New describe "Board: Focus restoration after overlay close":
  - closing the editor returns focus to body
  - closing the detail view returns focus to body
  - closing search returns focus to body
  - arrow keys work after editor round-trip (enter → enter → escape)
    — the exact flow the user reported as broken. Dispatches
    ArrowDown → Enter (detail) → Enter (editor) → Escape (close) →
    asserts body focus → ArrowDown → asserts .card-focused exists.
* Fixed .not.toBe() → (x !== y).toBe(true) since the custom runner
  doesn't have a .not chain.

chore: bump version to 0.9.14

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
thandClaude Opus 4.6 committed 2026-04-12 11:02:27 +02:00
1 parent b459159b0f
commit 88108ecc1b
8 files changed
+101 -5

No files matched your search

+6 -3
View File
@@ -236,9 +236,7 @@ function updateProgress(current, total, name, failed) {
}
function hideProgress() {
getProgressBar()?.remove();
// ensureProgressBar() in loader.js pushed the document down by 30px and
// shrunk it by the same amount so the footer wouldn't get clipped.
// Restore both inline overrides here.
document.getElementById('test-shield')?.remove();
document.body.style.marginTop = '';
document.body.style.height = '';
}
@@ -498,4 +496,9 @@ document.addEventListener('keydown', e => {
e.preventDefault();
panel ? close() : open();
}
if (e.key === 'Escape' && panel) {
e.preventDefault();
e.stopPropagation();
close();
}
});