mirror of
https://github.com/docmost/docmost.git
synced 2026-06-11 10:46:54 +08:00
fix(bases): suppress kanban column-body drop when a card target also matched
This commit is contained in:
@@ -23,16 +23,23 @@ export function useKanbanColumnDrop({
|
|||||||
return dropTargetForElements({
|
return dropTargetForElements({
|
||||||
element: el,
|
element: el,
|
||||||
canDrop: ({ source }) => source.data.type === "base-kanban-card",
|
canDrop: ({ source }) => source.data.type === "base-kanban-card",
|
||||||
|
// Keeps the column highlighted while the cursor passes over inner
|
||||||
|
// card drop targets, so the drop affordance doesn't flicker.
|
||||||
getIsSticky: () => true,
|
getIsSticky: () => true,
|
||||||
onDragEnter: () => setIsOver(true),
|
onDragEnter: () => setIsOver(true),
|
||||||
onDragLeave: () => setIsOver(false),
|
onDragLeave: () => setIsOver(false),
|
||||||
onDrop: ({ source }) => {
|
onDrop: ({ source, location }) => {
|
||||||
setIsOver(false);
|
setIsOver(false);
|
||||||
if (source.data.type !== "base-kanban-card") return;
|
if (source.data.type !== "base-kanban-card") return;
|
||||||
// If a card-level target inside this column already handled the
|
// Pragmatic-dnd fires onDrop on EVERY matching target in the ancestor
|
||||||
// drop, Pragmatic-dnd only invokes the innermost matching target,
|
// chain, not just the innermost. If a card-level target also matched
|
||||||
// so this column-body handler won't fire. When it does fire, the
|
// (the user dropped on a specific card, not on empty space below
|
||||||
// user missed every card — append to the column.
|
// the last card), the card target already dispatched the precise
|
||||||
|
// slot — bail so we don't double-fire and clobber its position.
|
||||||
|
const hitCardTarget = location.current.dropTargets.some(
|
||||||
|
(t) => (t.data as { type?: unknown }).type === "base-kanban-card-target",
|
||||||
|
);
|
||||||
|
if (hitCardTarget) return;
|
||||||
onDropRef.current({
|
onDropRef.current({
|
||||||
draggedCardId: source.data.cardId as string,
|
draggedCardId: source.data.cardId as string,
|
||||||
targetCardId: COLUMN_BODY_TARGET_ID,
|
targetCardId: COLUMN_BODY_TARGET_ID,
|
||||||
|
|||||||
Reference in New Issue
Block a user