Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decoration update while dead key is still active breaks backspace #1310

Closed
laurmaedje opened this issue Dec 15, 2023 · 4 comments
Closed

Decoration update while dead key is still active breaks backspace #1310

laurmaedje opened this issue Dec 15, 2023 · 4 comments

Comments

@laurmaedje
Copy link

laurmaedje commented Dec 15, 2023

Describe the issue

When a particular decoration update (mark + widget, as seen in the reproduction) is dispatched after a document update with a dead key, pressing backspace does nothing. In the same scenario, typing the dead key again inserts it twice into the editor.

How to reproduce:

  • Load reproduction
  • Type dead key, e.g. "^" on a German keyboard
  • Press backspace or type dead key again (different weird things happen)
    • Backspace: Sometimes the "^" is deleted, sometimes not. (It is not deleted if the browser's dead key indicator just disappears after a while, probably due to the decoration update.)
    • Dead key again: The dead key is inserted twice into the editor.

Browser and platform

Chrome, macOS, German Keyboard

Reproduction link

https://github.com/laurmaedje/codemirror-deco-bug

@marijnh
Copy link
Member

marijnh commented Dec 18, 2023

Your decoration widget will (by default) appear in front of the cursor when the cursor is at its precise position. That means the editor must render it between the cursor and the composed text. But doing that will unfortunately cause the browser to abort the composition and/or do the weird buggy things you're seeing.

Adding side: 1 to your widget decoration makes it sit after the cursor, which seems to prevent it from interfering with composition. Does that help?

@laurmaedje
Copy link
Author

That does seem to fix the problem in my reproduction. However, in my real application the problematic widget decoration is generated by the lint extension, which does not specify a side. Is there a way to apply this solution there?

@marijnh
Copy link
Member

marijnh commented Dec 19, 2023

Attached patch adds a kludge that, in this specific situation, avoids moving the DOM selection. The widget will show up on the wrong side of the cursor until the composition finishes, but that seems preferable to interrupting composition.

@laurmaedje
Copy link
Author

Great, thanks! I can confirm that this fixes the issue.

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

No branches or pull requests

2 participants