Closed Nantris closed 2 months ago
@marijnh any thoughts on this? Is there anything I can do to better clarify the problem? Unfortunately I'm not sure how to fix it despite mostly tracking it down.
A plain-prosemirror reproduction would be helpful. Also information about the browser/platform you tested with. I cannot reproduce this.
Thanks for your reply @marijnh and for trying to reproduce. Apologies for the lack of info - I produced this issue in Chrome and Electron.
Is there any ProseMirror CodeSandbox or the like that I could consult to start with? I regret to say that I am not sure how to produce a pure ProseMirror repro from scratch but if there's a boilerplate I'm sure I could figure it out eventually.
Following the basic example should make it rather straightforward to set up an editor.
Thanks for the tip @marijnh.
I adapted an existing sandbox I found so it could be more minimal, but the relevant code is easy to find and isolate https://codesandbox.io/p/sandbox/gallant-albattani-pcfh6s
If you open up the console you'll see when you press Shift-Alt-Minus
(Shift-Alt--
) it prints for the Alt-Minus
command as well. I couldn't replicate the particular finding that it only happened on every other press, but hopefully this repro helps to expose the overarching issue, and maybe the other issue would be resolved for us by coincidence.
I can't see this happen on Firefox or Chrome on Linux. Which keyboard layout, platform, and browser are you testing on? Specifically, does alt-minus produce a special character on that keyboard?
Hmm now that you mention it I do realize there's a discrepancy in the behavior between the minus key in the number bar and that in the number pad. The numpad minus key is the problematic one in this case and the number bar is unaffected.
I use a standard US QWERTY layout, so no special characters. I've seen the behavior in Chrome and Firefox on both Windows and Linux.
I'm on Chrome 123 and Firefox 123 on my machines.
Apparently you can use the browser's console to view the log statements rather than relying on CodeSandbox's emulated one.
Happy to do anything else I can to help illuminate the issue. Many thanks for your incredible work and effort @marijnh!
Right, numpad minus isn't modified by shift, so it'll still be seen and handled as a '-' press. It does call the handler for Shift-Alt--
first, and will only fall back to Alt--
when that returns false. This is intended behavior.
I should first mention that we're using TipTap. I'm not certain how to reproduce this in ProseMirror alone because I'm not sure how to setup an editor without TipTap - but I have very good reason to believe the issue is in ProseMirror rather than TipTap.
I examined the TipTap code and here you can see that TipTap binds the hotkeys using ProseMirror's
keymap
:https://github.com/ueberdosis/tiptap/blob/5a4c3baa0633105809469b20742094b01360a2be/packages/core/src/ExtensionManager.ts#L244-L254
I then set breakpoints in
prosemirror-keymap/dist/index.js
in our project and confirmed that the shortcut is being passed tokeymap
in an unaltered way (Shift-Alt--
andAlt--
)But when we press
Shift-Alt--
, every other time it's pressed, it triggers theAlt--
action.The closest I can get to a root cause is that
direct(view.state, view.dispatch, view)
alternates between returningtrue
andfalse
for seemingly identical input events. I don't know why the return value differs but I hope this is enough to hint at the underlying cause.