modifying styles during dragstart handler causes Chrome to fire dragend immediately on start
See original GitHub issueEDIT: not actually unique to captureDraggingState. It’s for any CSS change applied while dragstart
is still being handled.
https://bugs.chromium.org/p/chromium/issues/detail?id=168544
Workaround
Make any changes that cause style changes (e.g. firing actions that cause a class to be applied…) in a setTimeout(() => {}, 0)
wrapper.
Describe the bug
Usually with the HTML5 backend, one 'dragstart'
event fires when you drag something, and one 'dragend'
fires when you drop it.
Now, in Chrome, at least in v67, when you have captureDraggingState: true
, this is messed up. It goes:
- mouse down to drag an item, move it;
'dragstart'
'dragend'
immediately after that
- later, drop the item:
- no events fire
Because of this, you can’t actually drag anything – it is immediately dropped. Workaround is to drop IE11 DragLayer support by using the default value, false.
To Reproduce Steps to reproduce the behavior:
- On any example drag source, run connectDragPreview
with
{ captureDraggingState: true }` as its options. - Using Chrome dev tools, run
monitorEvents(document.body, 'dragstart')
andmonitorEvents(document.body, 'dragend')
. - Try to drag the source.
- Watch the console output.
- Also, observe that nothing happens under your mouse cursor, the drag barely happens at all.
Expected behavior
There should be no 'dragend'
until you drop, and you should be able to drag things.
Desktop (please complete the following information):
- OS: Windows 10
- Browser Chrome
- Version 67
It works fine in Firefox 60 on Windows.
Additional context
Technically I am using angular-skyhook
, but the code responsible for passing an Element/Node through to a backend with options is almost identical, even slightly simpler with no need for wrapConnectorHooks:
Issue Analytics
- State:
- Created 5 years ago
- Reactions:8
- Comments:8
Top GitHub Comments
@cormacrelf I ran into this problem today, in my case I have a list of draggable items (like a drawer with items), and when I start dragging I hide the drawer via CSS - at this point
dragend
fires and breaks dragging.I managed to bypass this behavior by using
setTimeout
to update CSS. It’s an ugly hack but solved my problem until a real fix lands.Code Example