codemirror / dev

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

Codemirror/view 6.28.0 breaks newlines in chrome 126 #1391

Closed jorg-vr closed 2 weeks ago

jorg-vr commented 3 weeks ago

Describe the issue

Issue

Pressing the 'enter' key when the editor is focused is completely ignored. No newlines are added. Pasting newlines still works.

Version

Codemirror/view 6.28.0 Chrome Version 126.0.6478.55 (Official Build) (64-bit)

Also tested in Firefox and chrome 114. The issue wasn't present there.

Reproduction

Create an editor without extensions

new EditorView({
  doc: "",
  extensions: [],
  parent: document.body
})

Workaround

Currently fixed by adding an extension:

keymap.of([
    {
        key: "Enter", run: insertNewline
    }
]),

see: https://github.com/dodona-edu/papyros/pull/710

Browser and platform

Chrome Version 126.0.6478.55 (Official Build) (64-bit) Linux mint

Reproduction link

https://codemirror.net/try/?c=aW1wb3J0IHtiYXNpY1NldHVwLCBFZGl0b3JWaWV3fSBmcm9tICJjb2RlbWlycm9yIgppbXBvcnQge2phdmFzY3JpcHR9IGZyb20gIkBjb2RlbWlycm9yL2xhbmctamF2YXNjcmlwdCIKCm5ldyBFZGl0b3JWaWV3KHsKICBkb2M6ICJjb25zb2xlLmxvZygnaGVsbG8nKVxuIiwKICBleHRlbnNpb25zOiBbXSwKICBwYXJlbnQ6IGRvY3VtZW50LmJvZHkKfSkK

marijnh commented 3 weeks ago

You'll want to actually bind enter to something with a keymap, like the default keymap.

marijnh commented 3 weeks ago

Oh, you already noticed that I see. The library provides no guarantee on any key behaving in any particular way (beyond text insertion) when you don't bind commands for them.

jorg-vr commented 3 weeks ago

Oh I didn't know we needed to explicitly add the standard keymap for 'Enter' to work. Odd that this behavior changed between versions though...

kylemcd commented 2 weeks ago

Adding to this, it seems that all non-manually binded keymaps are no longer working, examples like: CMD+F, CMD+Z. This seems like a regression to me, or at least a breaking change, as this totally borked our editor with the version upgrade.

marijnh commented 2 weeks ago

Ctrl-f works fine for me in that /try link (on Linux). For the undo history you definitely also want to wire in CodeMirror's implementation, since the native one is very flaky on a scripted editor like this.

marijnh commented 2 weeks ago

Just verified that cmd-f also still accesses the browser's native search on macOS Chrome.

jorg-vr commented 2 weeks ago

This issue is fixed in Codemirror/view 6.28.1

marijnh commented 2 weeks ago

Not really. That version temporarily disables EditContext, but later versions will enable it again. Just bind commands to your keys, you'll avoid a lot of problems, not just this one.