@@ -39,24 +39,40 @@ export const useTeamDragAndDrop = (eventId: string) => {
3939 })
4040 }
4141
42+ // Get both pointer and rect intersections
4243 const pointerIntersections = pointerWithin(args)
43- const intersections = pointerIntersections.length > 0 ? pointerIntersections : rectIntersection(args)
44+ const rectIntersections = rectIntersection(args)
45+
46+ // Combine both types of intersections, prioritizing pointer intersections
47+ const intersections = [...pointerIntersections, ...rectIntersections]
48+
49+ if (intersections.length === 0) {
50+ // If no intersections found and we have a last known position, maintain it
51+ // but only if it's still a valid container
52+ if (
53+ lastOverId.current &&
54+ args.droppableContainers.find((container) => container.id.toString() === lastOverId.current)
55+ ) {
56+ return [{ id: lastOverId.current }]
57+ }
58+ return []
59+ }
4460
4561 let overId = getFirstCollision(intersections, 'id')?.toString()
4662
4763 if (overId) {
4864 if (teamOrder.includes(overId)) {
4965 const teamMembers = localTeamData[overId] || []
5066 if (teamMembers.length > 0) {
51- const closestMember = closestCenter({
67+ const closestMemberCollisions = closestCenter({
5268 ...args,
5369 droppableContainers: args.droppableContainers.filter((container) =>
5470 teamMembers.some((m) => m.id === container.id.toString())
5571 ),
56- })[0]
72+ })
5773
58- if (closestMember ) {
59- overId = closestMember .id.toString()
74+ if (closestMemberCollisions.length > 0 ) {
75+ overId = closestMemberCollisions[0] .id.toString()
6076 }
6177 }
6278 }
@@ -65,7 +81,7 @@ export const useTeamDragAndDrop = (eventId: string) => {
6581 return [{ id: overId }]
6682 }
6783
68- return lastOverId.current ? [{ id: lastOverId.current }] : []
84+ return []
6985 },
7086 [activeItem, teamOrder, localTeamData]
7187 )
0 commit comments