Skip to content

fix: detect input elements across browser realms#140

Open
wojtowicz-artur wants to merge 1 commit into
TanStack:mainfrom
wojtowicz-artur:fix/cross-realm-input-detection
Open

fix: detect input elements across browser realms#140
wojtowicz-artur wants to merge 1 commit into
TanStack:mainfrom
wojtowicz-artur:fix/cross-realm-input-detection

Conversation

@wojtowicz-artur

@wojtowicz-artur wojtowicz-artur commented Jul 18, 2026

Copy link
Copy Markdown

🎯 Changes

Fixes #132

This was a subtle cross realm issue - instanceof checks break for elements coming from places like same-origin iframes. This PR switches ignoreInputs to normalized tagName checks, while keeping the existing behavior unchanged. It also adds a regression test to make sure this case stays fixed

✅ Checklist

  • I have followed the steps in the Contributing guide.
  • I have tested this code locally with pnpm run test:pr.

🚀 Release Impact

  • This change affects published code, and I have generated a changeset.
  • This change is docs/CI/dev-only (no release).

Summary by CodeRabbit

  • Bug Fixes

    • Improved hotkey handling for input fields, text areas, select elements, and editable content across different browser contexts.
    • Correctly excludes button, submit, and reset inputs from input detection.
  • Tests

    • Added coverage for input detection when browser DOM constructors differ between execution contexts.

@coderabbitai

coderabbitai Bot commented Jul 18, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

isInputElement no longer relies on current-realm DOM constructors. It identifies input-like elements through tagName and properties, adds cross-realm regression coverage, and records a patch release for @tanstack/hotkeys.

Changes

Cross-realm input detection

Layer / File(s) Summary
Cross-realm input classification
packages/hotkeys/src/manager.utils.ts, packages/hotkeys/tests/manager.utils.test.ts, .changeset/clean-cups-arrive.md
isInputElement classifies input, textarea, select, and strictly content-editable elements by properties, tests behavior with replaced DOM constructors, and adds a patch Changesets entry.

Estimated code review effort: 2 (Simple) | ~10 minutes

Poem

A rabbit hops through realms anew,
Tag names guide what keys should do.
Inputs, selects, textareas align,
While buttons neatly stay in line.
Tests guard the burrow bright—
Patch notes thump into the night.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The code and test changes address #132 by replacing realm-specific instanceof checks with tagName-based detection.
Out of Scope Changes check ✅ Passed The changeset and test coverage are in scope for the bug fix and release impact.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Title check ✅ Passed The title clearly summarizes the main change: cross-realm input-element detection.
Description check ✅ Passed The description follows the template with Changes, Checklist, and Release Impact sections and includes the required release note.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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.

ignoreInput isn't detected across realms

1 participant