react-dnd icon indicating copy to clipboard operation
react-dnd copied to clipboard

Changing Drag Item Type Breaks Drag Preview

Open jacklimwenjie opened this issue 6 years ago • 2 comments

Describe the bug

Using the DragSource legacy decorator API, after the item spec type key is changed, differs from its initial value, the drag preview is left with only the drag source.

Reproduction

Live Reproduction

I'm using the "Handle" text as the drag handle, and the drag preview should include both the "Handle" text and the message below it.

Steps to reproduce the behavior:

  1. Verify that the preview is working fine initially by dragging the items by the "Handle" text.
  2. Click on the "Change Message" button to change the message. Verify that the preview is still working fine.
  3. Click on the "Change Type" button to change the type. Note that now the preview is left with the "Handle" text.

Expected behavior The preview should still work as before the drag item type is changed, which includes the "Handle" text and the message below it.

Desktop (please complete the following information):

  • OS: MacOS
  • Browser: Chrome
  • Version: 84.0.4147.135 (Official Build) (64-bit)

jacklimwenjie avatar Sep 01 '20 10:09 jacklimwenjie

Have you found a workaround for this? I'm having the same issue

L-u-k-e avatar Dec 19 '21 23:12 L-u-k-e

In case this helps anyone. I'm using the hooks api and i was able to work around my problem by calling the useDrag() hook once for every item type I needed to support (instead of calling useDrag one type and dynamically setting the item type option).

Then I dynamically assigned the correct ref in my render function

L-u-k-e avatar Dec 20 '21 21:12 L-u-k-e