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

[Bug]: Caps lock + enter create two list items #6032

Open
1 task done
Gaurussel opened this issue Jan 17, 2025 · 4 comments
Open
1 task done

[Bug]: Caps lock + enter create two list items #6032

Gaurussel opened this issue Jan 17, 2025 · 4 comments
Labels
Category: Open Source The issue or pull reuqest is related to the open source packages of Tiptap. Type: Bug The issue or pullrequest is related to a bug

Comments

@Gaurussel
Copy link

Affected Packages

extension-bulletlist, extension-orderedlist, extension-tasklist

Version(s)

latest

Bug Description

With enabled "Use caps..." in macOS settings on pressing capslock with enter created two list items.

Image

Browser Used

Chrome

Code Example URL

No response

Expected Behavior

Created only one list item

Additional Context (Optional)

Screen.Recording.2025-01-17.at.20.34.50.mov

Dependency Updates

  • Yes, I've updated all my dependencies.
@Gaurussel Gaurussel added Category: Open Source The issue or pull reuqest is related to the open source packages of Tiptap. Type: Bug The issue or pullrequest is related to a bug labels Jan 17, 2025
@Nantris
Copy link
Contributor

Nantris commented Jan 18, 2025

It would be useful to document what events are firing in the keydown and beforeinput listeners. You can make a ProseMirror plugin using handleDOMEvents to log them out.

@guanriyue
Copy link
Contributor

This is neither a Tiptap issue nor a ProseMirror issue. It seems there is some special handling of keyboard events in the browser.

I used a plain <textarea> to demonstrate. After pressing Caps Lock, if you immediately press a number or letter key, such as the number 9, it will trigger KeyboardEvent[key=Unidentified] once, followed by another KeyboardEvent[key=9]. However, if you immediately press the Enter key, it will trigger two consecutive KeyboardEvent[key=Enter] events.

2025-01-20.15.49.29.mov

For the Unidentified case, refer to MDN documentation. But why is the Enter key recognized correctly? I don't have experience with this kind of issue. In fact, I also tried Backspace, and it too was triggered twice.

You might consider reaching out to ProseMirror's author, Marijn, for advice. The addKeyboardShortcuts feature essentially uses prosemirror-keymap under the hood. In your example, the Enter key event triggered ListItem.addKeyboardShortcuts.Enter. Naturally, since two KeyboardEvent[key=Enter] events were dispatched due to input behavior, the shortcut was triggered twice, resulting in two listItem elements being added.

@guanriyue
Copy link
Contributor

It seems that this behavior triggers the beforeinput event only once (and the keypress event also triggers only once), which might be helpful in resolving this issue.

Image

@nperez0111
Copy link
Contributor

I think this would probably have to be handled by prosemirror, not here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Category: Open Source The issue or pull reuqest is related to the open source packages of Tiptap. Type: Bug The issue or pullrequest is related to a bug
Projects
None yet
Development

No branches or pull requests

4 participants