SortableJS / Sortable

Reorderable drag-and-drop lists for modern browsers and touch devices. No jQuery or framework required.
https://sortablejs.github.io/Sortable/
MIT License
29.77k stars 3.71k forks source link

SetData did not have any effect #2343

Closed Niefee closed 10 months ago

Niefee commented 10 months ago
  setData: (dataTransfer: any, dragEl: any) => {
      console.log('dataTransfer:', dataTransfer);
      console.log('dragEl:', dragEl);
      dataTransfer.setData('Text', dragEl.textContent);
  },

The above settings were not executed

Destination List:

onAdd: (evt) => {
    const data = JSON.parse(evt.originalEvent.dataTransfer.getData('Text'));
    console.log('onAdd data: ', data);
}

Error reported above. evt.originalEvent.dataTransfer is null.

VikasRajput-18 commented 10 months ago

can i work on this?

owen-m1 commented 10 months ago

Do you have forceFallback enabled (forceFallback: true), or are on mobile?

owen-m1 commented 10 months ago

Okay, it will not work if fallback is enabled, the dataTransfer is something that's only available in the native drag & drop browser API.