Dropcursor won't remove the cursor if default drop event is prevented from custom handler #1385

Open
opened 2023-06-06 14:28:49 +02:00 by eric-burel · 3 comments
eric-burel commented 2023-06-06 14:28:49 +02:00 (Migrated from github.com)

Hi,

I couldn't build a repro because the Glitch doesn't allow to require prosemirror-dropcursor, but the bug is simple:

  1. Install dropcursor
  2. Write a custom drop handler that calls event.preventDefault(). I do not return anything from this handler.
  3. Drop something: the cursor stays up for 5 secondes instead of 20ms because "dropcursor" never catches the drop event

It seems to me that dropcursor should have a kind of "priority" over the default drop handlers. Removing preventDefault() from my custom handler is possible but perhaps not recommended are you are supposed to call it in drop event handlers when you accept the drop, unless I misunderstand something specific to prosemirror.

Returning "true" at the end seems to have no effect.

<!-- Please provide: - Necessary steps to reproduce the issue. If the editor has to be set up in a specific way, running code (minimal code, not a dump of your project) is very useful. Possibly start from https://glitch.com/edit/#!/remix/prosemirror-demo-basic. - If this might be browser-related, tell us the browsers and platforms you tested on. --> Hi, I couldn't build a repro because the Glitch doesn't allow to require `prosemirror-dropcursor`, but the bug is simple: 1) Install dropcursor 2) Write a custom drop handler that calls `event.preventDefault()`. I do not return anything from this handler. 3) Drop something: the cursor stays up for 5 secondes instead of 20ms because "dropcursor" never catches the drop event It seems to me that dropcursor should have a kind of "priority" over the default drop handlers. Removing `preventDefault()` from my custom handler is possible but perhaps not recommended are you are supposed to call it in drop event handlers when you accept the drop, unless I misunderstand something specific to prosemirror. Returning "true" at the end seems to have no effect.
marijnh commented 2023-06-06 15:12:54 +02:00 (Migrated from github.com)

Does putting your custom plugin after the dropcursor plugin in the extension array help?

Does putting your custom plugin _after_ the dropcursor plugin in the extension array help?
eric-burel commented 2023-06-06 15:32:48 +02:00 (Migrated from github.com)

It's a custom event handler, defined using  handleDOMEvents, so not a plugin I would have tried that otherwise.

Edit: perhaps there is a way to have a plugin to add events to "handleDOMEvents", instead of listeneing to direct events? So we can control the order in which they run more cleanly?

In the meantime I'll probably copy dropcursor in my app and handle the rendering more directly

It's a custom event handler, defined using  `handleDOMEvents`, so not a plugin I would have tried that otherwise. Edit: perhaps there is a way to have a plugin to add events to "handleDOMEvents", instead of listeneing to direct events? So we can control the order in which they run more cleanly? In the meantime I'll probably copy dropcursor in my app and handle the rendering more directly
marijnh commented 2023-06-06 18:18:57 +02:00 (Migrated from github.com)

You can create a plugin with props: {handleDOMEvents: {...}}

You can create a plugin with `props: {handleDOMEvents: {...}}`
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
prosemirror/prosemirror#1385
No description provided.