Filter invalid nested drag targets before collision selection
This commit is contained in:
1 parent
88207cdd48
commit
ca2fcb4016
3 files changed
+27
-4
No files matched your search
@@ -121,7 +121,15 @@ export function createDndManager(options: DndManagerOptions): DndManager {
|
||||
element: registration.element,
|
||||
handle: registration.handle,
|
||||
type: registration.type,
|
||||
accept: registration.accepts,
|
||||
accept: (source) => {
|
||||
const origin = entries.get(source.id)?.current.element;
|
||||
// A nested ancestor overlaps its own descendants and must not steal
|
||||
// their next keyboard/pointer target just because its box is larger.
|
||||
if (source.id !== registration.id && origin && registration.element.contains?.(origin)) return false;
|
||||
if (registration.accepts && !registration.accepts.some(type => type === source.type)) return false;
|
||||
const target = entries.get(registration.id)?.sortable;
|
||||
return options.accept?.([source.id], { group: target?.group ?? registration.group, index: target?.index ?? registration.index }) ?? true;
|
||||
},
|
||||
disabled: registration.disabled,
|
||||
transition: reducedMotion ? null : undefined,
|
||||
data: { ...registration.data, direction },
|
||||
|
||||
Reference in new issue
Block a user