Skip to content

feat: add unfocused tab fallbacks for clear() and keyboard() in userEvent proxy#205

Merged
kevinccbsg merged 1 commit into
mainfrom
feature/userevent-unfocused-fallbacks
Apr 12, 2026
Merged

feat: add unfocused tab fallbacks for clear() and keyboard() in userEvent proxy#205
kevinccbsg merged 1 commit into
mainfrom
feature/userevent-unfocused-fallbacks

Conversation

@kevinccbsg

Copy link
Copy Markdown
Member

Summary

  • Adds a clearFallback helper that reuses typingFallback with an empty string, avoiding code duplication
  • Adds unfocused fallback for clear() — uses native value setter to set "" and dispatches input/change events so React picks up the change when the tab is backgrounded
  • Adds unfocused fallback for keyboard('{Tab}') — dispatches blur + focusout on document.activeElement to trigger framework validation (e.g. React Hook Form) when the tab is not focused

Fixes flaky tests in the AI relay workflow where the browser tab loses focus during full suite runs via twd-relay.

Test plan

  • Red/green TDD cycle followed — tests were written against commented-out implementation, confirmed failing, then implementation was uncommented
  • 4 new tests covering clear and keyboard fallbacks for both hidden and no-focus scenarios
  • All 354 tests pass (npm run test:ci)

🤖 Generated with Claude Code

…vent proxy

Adds fallbacks for clear() and keyboard('{Tab}') when the browser tab is
backgrounded, matching the existing type() fallback pattern so tests remain
reliable in the AI relay workflow (tab loses focus).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@kevinccbsg kevinccbsg merged commit af6eea2 into main Apr 12, 2026
8 checks passed
@kevinccbsg kevinccbsg deleted the feature/userevent-unfocused-fallbacks branch April 12, 2026 18:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant