fix: Drag and drop images in editor, conflict with sidebar react-dnd (#1918)

* fix: Drag and drop images in editor, conflict with sidebar react-dnd
see: https://github.com/react-dnd/react-dnd/pull/3052

* Bump to non-canary

* Upgrade react-dnd

* react-dnd api changes

* lint

* fix: dnd doesn't work on first render

* remove unneccessary async

* chore: Update react-dnd (API changed again)

* restore fade
This commit is contained in:
Tom Moor
2021-03-09 18:41:30 -08:00
committed by GitHub
parent ed2a42ac27
commit bac7a364d0
8 changed files with 321 additions and 323 deletions

View File

@@ -35,7 +35,7 @@ class Collections extends React.Component<Props> {
componentDidMount() {
const { collections } = this.props;
if (!collections.isFetching && !collections.isLoaded) {
if (!collections.isLoaded) {
collections.fetchPage({ limit: 100 });
}
}

View File

@@ -123,7 +123,8 @@ function DocumentLink({
// Draggable
const [{ isDragging }, drag] = useDrag({
item: { type: "document", ...node, depth, active: isActiveDocument },
type: "document",
item: () => ({ ...node, depth, active: isActiveDocument }),
collect: (monitor) => ({
isDragging: !!monitor.isDragging(),
}),
@@ -146,7 +147,7 @@ function DocumentLink({
// Drop to re-parent
const [{ isOverReparent, canDropToReparent }, dropToReparent] = useDrop({
accept: "document",
drop: async (item, monitor) => {
drop: (item, monitor) => {
if (monitor.didDrop()) return;
if (!collection) return;
documents.move(item.id, collection.id, node.id);
@@ -183,7 +184,7 @@ function DocumentLink({
// Drop to reorder
const [{ isOverReorder }, dropToReorder] = useDrop({
accept: "document",
drop: async (item, monitor) => {
drop: (item, monitor) => {
if (!collection) return;
if (item.id === node.id) return;