Skip to content

Commit

Permalink
refactor: fix direction collision by avoiding duplicate drop refs
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisvxd committed Oct 10, 2024
1 parent be744d7 commit 3786cfc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ export const createDynamicCollisionDetector = (
midpointOffset: number = 0.05
) =>
((input) => {
// console.log("checking collision", input);
const { dragOperation, droppable } = input;

const { position } = dragOperation;
Expand Down Expand Up @@ -66,6 +65,8 @@ export const createDynamicCollisionDetector = (

const collision = directionalCollision(input, interval.previous);

collisionDebug(dragCenter, dropCenter, droppable.id.toString(), "yellow");

if (collision) {
return {
...collision,
Expand Down
13 changes: 6 additions & 7 deletions packages/core/components/DropZone/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -211,13 +211,12 @@ function DropZoneEdit({
ref={(node) => {
ref.current = node;

// dnd-kit gets confused if both drop and drag refs are assigned during a drag.
// Luckily, during a drag, isDropEnabled === false for this item, so we can
// remove the ref.
// TODO see if there's a fix for this upstream
// if (isDropEnabled) {
dropRef(node);
// }
// Don't apply dropRef if we have a dragRef, which is actually a
// sortableRef and so already includes drop reference. Including
// both confuses dnd-kit
if (!dragRef) {
dropRef(node);
}

if (dragRef) dragRef(node);
}}
Expand Down

0 comments on commit 3786cfc

Please sign in to comment.