Skip to content
This repository was archived by the owner on Apr 15, 2026. It is now read-only.
This repository was archived by the owner on Apr 15, 2026. It is now read-only.

EditContext intercepts input after focus is programmatically transferred #1458

Closed

Description

@chuanqisun

Describe the issue

Minimum repro: https://stackblitz.com/edit/vitejs-vite-y35czl?file=main.js

  <div id="editor-root"></div>
  <div>
    <button>transfer focus</button>
    <input id="input-element" />
  </div>
new EditorView({
  doc: `hello world `,
  extensions: [],
  parent: document.getElementById('editor-root'),
});

document.querySelector('button').onfocus = () =>
  document.querySelector('input').focus();

Repro recording

repro.mp4

Repro step

  1. Click inside the text editor to set focus
  2. Click "transfer focus" button
  3. Observe blinking cursor in text input
  4. Type anything

Expect: text input to receive all keyboard events
Actual: editor receives all keyboard events

  1. Set EditorView.EDIT_CONTEXT = false;
  2. Repeat steps, observe that issue goes away

Additional context

I need to move focus from one element to another as part of an accessibility focus trap implementation. In the real code, the element that transfers focus are dummy elements at the beginning and end of the focus trapped area.

Browser and platform

Chrome in Linux, Windows, and MacOS

Reproduction link

https://stackblitz.com/edit/vitejs-vite-y35czl?file=main.js

Activity

  1. marijnh commented on Oct 27, 2024

    @marijnh
    Member

    That appears to be another bug in Chrome's implementation of EditContext. I've reported it as issue 375711382. Until they fix it, the only advice I can offer is to set up your event handlers to avoid triggering this.

  2. chuanqisun commented on Oct 28, 2024

    @chuanqisun
    Author

    Thank you for distilling the repro and reporting to Chrome.

  3. vezaynk commented on Apr 23, 2025

    @vezaynk

    Thank you for this issue. Adding EditorView.EDIT_CONTEXT = false; did fix the trick for us. Not sure what we're losing out on by doing it.

  4. kjk commented on Jul 7, 2025

    @kjk
  5. marijnh commented on Jul 7, 2025

    @marijnh
    Member

    Great! I'll close this then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions