Slate: Drag & drop of nested elements in 0.57.x

Created on 27 Feb 2020  ·  5Comments  ·  Source: ianstormtaylor/slate

Do you want to request a _feature_ or report a _bug_?

🐛

What's the current behavior?

Slate: 0.57.1
Browser: Chrome
OS: Mac

https://codesandbox.io/s/slate-reproductions-7klqo

  • Dragging and dropping a nested element (in this example, a div with a paragraph child) does not work as expected.
  • Element is not placed where the user's cursor was when dropped.
  • Original element is not removed after dropping.
    nw5YwtaEl7

What's the expected behavior?

  • Element is placed where the user's cursor was when they dropped the element.
  • The original element is removed.
bug

Most helpful comment

Though this isn't a fix for this problem, I thought I would add a link here to a naive implementation of a drag and drop implementation of slate with the react-beautiful-dnd library in case it is helpful for anyone. :-)

https://codesandbox.io/s/vertical-list-nixx4

All 5 comments

it seems like can write like this:

<div
    draggable="true"
    style={{ backgroundColor: 'red', width: '200px' }}
    onDragStart={...}
    onDragOver={...}
    onDrop={...}>
    ...
</div>

it seems like can write like this:

<div
    draggable="true"
    style={{ backgroundColor: 'red', width: '200px' }}
    onDragStart={...}
    onDragOver={...}
    onDrop={...}>
    ...
</div>

Thanks for you comment, @Elvenisboy ! Do you have a sandbox example using this? I just tried it with the sandbox I provided in the issue but it unfortunately does not fix the issue.

似乎可以这样写:

<div
    draggable="true"
    style={{ backgroundColor: 'red', width: '200px' }}
    onDragStart={...}
    onDragOver={...}
    onDrop={...}>
    ...
</div>

感谢您的评论,@ Elvenisboy!您是否有使用此功能的沙箱示例?我只是在问题中提供的沙箱中尝试过,但是很遗憾,它无法解决问题。

Sure, @DianaLease just see here https://codesandbox.io/s/example-for-issues-3522-1meyy

I don't konw how to swap nodes by slate native, so I use context.

Although It need more code, it works well

The same issue can be replicated on https://www.slatejs.org/examples/richtext
Browser: Firefox 74.0
OS : Ubuntu
slate

Though this isn't a fix for this problem, I thought I would add a link here to a naive implementation of a drag and drop implementation of slate with the react-beautiful-dnd library in case it is helpful for anyone. :-)

https://codesandbox.io/s/vertical-list-nixx4

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ezakto picture ezakto  ·  3Comments

gorillatron picture gorillatron  ·  3Comments

ianstormtaylor picture ianstormtaylor  ·  3Comments

varoot picture varoot  ·  3Comments

YurkaninRyan picture YurkaninRyan  ·  3Comments