Skip to content

Commit 6a72d92

Browse files
committed
Fix flash of red on drop
1 parent 908d1ee commit 6a72d92

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

src/node-renderer-default.js

+8-5
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ const NodeRendererDefault = ({
2121
connectDragPreview,
2222
connectDragSource,
2323
isDragging,
24-
isOver,
2524
canDrop,
2625
node,
2726
draggedNode,
@@ -32,8 +31,10 @@ const NodeRendererDefault = ({
3231
buttons,
3332
className,
3433
style = {},
35-
startDrag: _startDrag,
36-
endDrag: _endDrag,
34+
didDrop,
35+
isOver: _isOver, // Not needed, but preserved for other renderers
36+
endDrag: _endDrag, // Needed for drag-and-drop utils
37+
startDrag: _startDrag, // Needed for drag-and-drop utils
3738
...otherProps,
3839
}) => {
3940
let handle;
@@ -66,6 +67,7 @@ const NodeRendererDefault = ({
6667
}
6768

6869
const isDraggedDescendant = draggedNode && isDescendant(draggedNode, node);
70+
const isLandingPadActive = !didDrop && isDragging;
6971

7072
return (
7173
<div
@@ -95,8 +97,8 @@ const NodeRendererDefault = ({
9597
{connectDragPreview(
9698
<div
9799
className={styles.row +
98-
(isDragging && isOver ? ` ${styles.rowLandingPad}` : '') +
99-
(isDragging && !isOver && canDrop ? ` ${styles.rowCancelPad}` : '') +
100+
(isLandingPadActive ? ` ${styles.rowLandingPad}` : '') +
101+
(isLandingPadActive && !canDrop ? ` ${styles.rowCancelPad}` : '') +
100102
(isSearchMatch ? ` ${styles.rowSearchMatch}` : '') +
101103
(isSearchFocus ? ` ${styles.rowSearchFocus}` : '') +
102104
(className ? ` ${className}` : '')
@@ -166,6 +168,7 @@ NodeRendererDefault.propTypes = {
166168
startDrag: PropTypes.func.isRequired, // Needed for drag-and-drop utils
167169
endDrag: PropTypes.func.isRequired, // Needed for drag-and-drop utils
168170
isDragging: PropTypes.bool.isRequired,
171+
didDrop: PropTypes.bool.isRequired,
169172
draggedNode: PropTypes.object,
170173
// Drop target
171174
isOver: PropTypes.bool.isRequired,

src/utils/drag-and-drop-utils.js

+1
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ function nodeDragSourcePropInjection(connect, monitor) {
138138
connectDragSource: connect.dragSource(),
139139
connectDragPreview: connect.dragPreview(),
140140
isDragging: monitor.isDragging(),
141+
didDrop: monitor.didDrop(),
141142
};
142143
}
143144

0 commit comments

Comments
 (0)