Skip to content

Fix Focus Management (17 test failures) #262

Closed

Description

@malibio

Bug: Focus Management Failures

Related to: Issue #208 (Comprehensive Test Coverage)
Test File: src/tests/integration/focus-management.test.ts
Failures: 17 tests

Problem

Focus management tests are failing across multiple scenarios:

Modal Focus - Autocomplete (5 failures)

  • should maintain editor focus even when typing trigger characters
  • should maintain editor focus when typing slash character
  • should maintain focus when pressing Enter after typing
  • should maintain focus when pressing Escape
  • should trap focus within modal context when Tab is pressed

Node Creation Focus (4 failures)

  • should maintain editor focus after Enter key press
  • should position cursor at start of new node after Enter
  • should preserve editor focusability after content split with Enter
  • should support programmatic focus via autoFocus prop

Focus Restoration (3 failures)

  • should allow manual focus restoration after blur
  • should maintain focus during arrow key navigation within editor
  • should maintain focus during text selection

Slash Command Focus (3 failures)

  • should maintain editor focus after slash command insertion
  • should auto-focus editor after node type conversion via slash command
  • should maintain focus if autocomplete trigger fails

Error Handling (2 failures)

  • should maintain focusability after user interaction
  • should maintain focus if slash command fails

Root Causes

Likely issues:

  1. Modal components (autocomplete, slash dropdown) stealing focus
  2. Improper focus restoration after keyboard operations
  3. Missing autoFocus prop handling in node components
  4. Focus lost during async operations

Acceptance Criteria

  • All 17 focus management tests pass
  • Editor maintains focus during:
    • Modal interactions (autocomplete, slash commands)
    • Node creation/deletion operations
    • Arrow key navigation
    • Text selection
  • Proper focus restoration after blur events
  • Tab trapping works correctly in modal contexts
  • Quality checks pass: bun run quality:fix

Testing

Run: bun run test src/tests/integration/focus-management.test.ts

Estimated Effort

  • Time: 3-4 hours
  • Complexity: Medium-High (requires DOM focus API understanding)
  • Risk: Medium (affects user interaction quality)

Activity

  1. malibio commented on Oct 13, 2025

    @malibio
    CollaboratorAuthor

    ✅ ALL 17 TESTS NOW PASSING

    Verified with:

    bun run test src/tests/integration/focus-management.test.ts
    # Result: ✓ 17 tests passed

    The failures were resolved by recent commits (likely PR #268 for #258 or other refactoring work).

    This reduces remaining failures from 65 → 48.

    Closing as resolved.

  2. malibio commented on Oct 13, 2025

    @malibio
    CollaboratorAuthor

    ⚠️ REOPENING - Test Isolation Issue

    The tests PASS when run in isolation:

    bun run test src/tests/integration/focus-management.test.ts
    # ✓ 17 tests passed

    But FAIL when run as part of the full test suite:

    bun run test
    # ✗ 17 focus-management tests failed

    This indicates a test isolation problem - likely:

    • Shared state not being cleaned up between test files
    • Global event listeners leaking
    • Focus state persisting from previous tests
    • DOM state not being reset properly

    This is a real bug that needs investigation. The issue is not with the focus management code itself, but with test suite isolation.

  3. self-assigned this
    on Oct 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions