File tree Expand file tree Collapse file tree 2 files changed +9
-4
lines changed
packages/react-arborist/src Expand file tree Collapse file tree 2 files changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -33,13 +33,18 @@ export function useDropHook(
33
33
} ) ;
34
34
if ( ! drop ) return false ;
35
35
const dropParent = tree . get ( drop . parentId ) ?? tree . root ;
36
-
37
- for ( let id of item . dragIds ) {
38
- const drag = tree . get ( id ) ;
36
+
37
+ const dragNodes = < NodeApi [ ] > item . dragIds . map ( tree . get , tree ) ;
38
+ for ( const drag of dragNodes ) {
39
39
if ( ! drag ) return false ;
40
40
if ( ! dropParent ) return false ;
41
41
if ( drag . isInternal && isDecendent ( dropParent , drag ) ) return false ;
42
42
}
43
+
44
+ const check = tree . props . disableDrop ;
45
+ if ( typeof check === 'function' && check ( dropParent , dragNodes ) ) {
46
+ return false ;
47
+ }
43
48
return true ;
44
49
} ,
45
50
hover : ( item , m ) => {
Original file line number Diff line number Diff line change @@ -40,7 +40,7 @@ export interface TreeProps<T> {
40
40
disableMultiSelection ?: boolean ;
41
41
disableEdit ?: string | boolean | BoolFunc < T > ;
42
42
disableDrag ?: string | boolean | BoolFunc < T > ;
43
- disableDrop ?: string | boolean | BoolFunc < T > ;
43
+ disableDrop ?: string | boolean | BoolFunc < T > | ( ( node : NodeApi , dragNodes : NodeApi [ ] ) => boolean ) ;
44
44
childrenAccessor ?: string | ( ( d : T ) => T [ ] | null ) ;
45
45
idAccessor ?: string | ( ( d : T ) => string ) ;
46
46
You can’t perform that action at this time.
0 commit comments