Skip to content

Commit e7d2371

Browse files
committed
fix: don't collide with parent if component contains drop zone
1 parent 1e8a3ae commit e7d2371

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

packages/core/components/DropZone/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -386,15 +386,15 @@ export const DropZoneEdit = forwardRef<HTMLDivElement, DropZoneProps>(
386386

387387
useEffect(() => {
388388
if (registerLocalZone) {
389-
registerLocalZone(zoneCompound, isEnabled);
389+
registerLocalZone(zoneCompound, targetAccepted || isEnabled);
390390
}
391391

392392
return () => {
393393
if (unregisterLocalZone) {
394394
unregisterLocalZone(zoneCompound);
395395
}
396396
};
397-
}, [isEnabled, zoneCompound]);
397+
}, [targetAccepted, isEnabled, zoneCompound]);
398398

399399
const [contentIdsWithPreview, preview] = useContentIdsWithPreview(
400400
contentIds,

packages/core/lib/dnd/NestedDroppablePlugin.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,8 +210,17 @@ export const findDeepestCandidate = (
210210

211211
filteredCandidates.reverse();
212212

213-
const zone = getZoneId(filteredCandidates[0]);
214-
const area = filteredCandidates[0]?.data.areaId;
213+
const primaryCandidate = filteredCandidates[0];
214+
const primaryCandidateData = primaryCandidate.data as
215+
| ComponentDndData
216+
| DropZoneDndData;
217+
const primaryCandidateIsComponent =
218+
"containsActiveZone" in primaryCandidateData;
219+
const zone = getZoneId(primaryCandidate);
220+
const area =
221+
primaryCandidateIsComponent && primaryCandidateData.containsActiveZone
222+
? filteredCandidates[0].id
223+
: filteredCandidates[0]?.data.areaId;
215224

216225
return { zone, area };
217226
}

0 commit comments

Comments
 (0)