codemirror / dev

Development repository for the CodeMirror editor project
https://codemirror.net/
Other
5.94k stars 376 forks source link

ViewEditor removed from DOM still captures input on Google Chrome #1428

Closed Corb3nik closed 3 months ago

Corb3nik commented 3 months ago

Describe the issue

Hi!

On Google Chrome, when an editor is removed from the DOM, it still captures keystrokes, preventing other input elements from receiving keystrokes.

Steps to Reproduce

  1. Open the reproduction link
  2. Type in the editor
  3. Wait 5s, the DOM will be replaced with a new input tag
  4. Attempt to type in the new input tag

The new input tag won't receive any keystrokes.

https://github.com/user-attachments/assets/5751dec7-4a12-45ee-95cf-2a1052175c05

Browser and platform

macOS (14.6) / Google Chrome (Version 127.0.6533.89)

Reproduction link

https://codemirror.net/try/?c=aW1wb3J0IHsgRWRpdG9yVmlldyB9IGZyb20gIkBjb2RlbWlycm9yL3ZpZXciOwoKY29uc3QgdmlldyA9IG5ldyBFZGl0b3JWaWV3KHsKICBkb2M6ICJUeXBlIGhlcmUiLAogIHBhcmVudDogZG9jdW1lbnQuYm9keSwKfSk7CgpzZXRUaW1lb3V0KCgpID0+IHsKICBkb2N1bWVudC53cml0ZSgiPGlucHV0PiIpOwp9LCA1MDAwKTsK

marijnh commented 3 months ago

This is a Chrome bug that should be fixed in version 128. If you can arrange to call destroy() on the editor when it is being removed, that will avoid the issue. Beyond that, there's unfortunately not much the library can do about this, so I'm closing this issue here.