Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion newIDE/app/src/UI/DragAndDrop/CustomDragLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,8 @@ const CustomDragLayer = ({
const screenType = useScreenType();
const renderedItem = React.useMemo(
() => {
if (!item || !clientOffset) return null;
if (!item || (!item.name && !item.thumbnail) || !clientOffset)
return null;

if (shouldHidePreviewBecauseDraggingOnSceneEditorCanvas(clientOffset)) {
return null;
Expand Down
14 changes: 10 additions & 4 deletions newIDE/app/src/UI/TreeView/TreeViewRow.js
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,15 @@ const TreeViewRow = <Item: ItemBaseAttributes>(props: Props<Item>) => {
<div style={style} ref={containerRef}>
<DragSourceAndDropTarget
beginDrag={() => {
// During a long-press (which will open the context menu on mobile), suppress
// the drag preview by returning an item with no data. We cannot block canDrag()
// instead, because react-dnd-touch-backend evaluates canDrag() once (after its
// delayTouchStart of 100ms), at which point isPressingRef is always true — so
// blocking canDrag() would permanently break intentional drags on mobile.
if (isLongTouchPressingRef.current) {
return {};
}

if (!node.selected) onSelect({ node, exclusive: !node.selected });

if (forceDefaultDraggingPreview) {
Expand Down Expand Up @@ -306,10 +315,7 @@ const TreeViewRow = <Item: ItemBaseAttributes>(props: Props<Item>) => {
!node.item.isRoot &&
!node.item.isPlaceholder &&
// Prevent dragging of item whose name is edited, allowing to select text with click and drag on text.
renamedItemId !== node.id &&
// Prevent drag from starting during a long-press (which opens the context menu on mobile).
// When the user moves their finger, useLongTouch cancels, clearing isPressingRef, re-enabling drag.
!isLongTouchPressingRef.current
renamedItemId !== node.id
}
canDrop={canDrop ? () => canDrop(node.item, whereToDrop) : () => true}
drop={() => {
Expand Down
Loading