@@ -11,7 +11,7 @@ import {
11
11
useRef ,
12
12
useState ,
13
13
} from "react" ;
14
- import { defaultPreset , DragDropManager } from "@dnd-kit/dom" ;
14
+ import { AutoScroller , defaultPreset , DragDropManager } from "@dnd-kit/dom" ;
15
15
import { DragDropEvents } from "@dnd-kit/abstract" ;
16
16
import { DropZoneProvider } from "../DropZone" ;
17
17
import type { Draggable , Droppable } from "@dnd-kit/dom" ;
@@ -76,7 +76,15 @@ type DeepestParams = {
76
76
77
77
const AREA_CHANGE_DEBOUNCE_MS = 100 ;
78
78
79
- const DragDropContextClient = ( { children } : { children : ReactNode } ) => {
79
+ type DragDropContextProps = {
80
+ children : ReactNode ;
81
+ disableAutoScroll ?: boolean ;
82
+ } ;
83
+
84
+ const DragDropContextClient = ( {
85
+ children,
86
+ disableAutoScroll,
87
+ } : DragDropContextProps ) => {
80
88
const { state, config, dispatch, resolveData } = useAppContext ( ) ;
81
89
82
90
const [ preview , setPreview ] = useState < Preview > ( null ) ;
@@ -118,7 +126,9 @@ const DragDropContextClient = ({ children }: { children: ReactNode }) => {
118
126
} ;
119
127
120
128
const [ plugins ] = useState ( ( ) => [
121
- ...defaultPreset . plugins ,
129
+ ...( disableAutoScroll
130
+ ? defaultPreset . plugins . filter ( ( plugin ) => plugin !== AutoScroller )
131
+ : defaultPreset . plugins ) ,
122
132
createNestedDroppablePlugin ( {
123
133
onChange : ( params , manager ) => {
124
134
const lastParams = deepestRef . current ;
@@ -473,12 +483,19 @@ const DragDropContextClient = ({ children }: { children: ReactNode }) => {
473
483
) ;
474
484
} ;
475
485
476
- export const DragDropContext = ( { children } : { children : ReactNode } ) => {
486
+ export const DragDropContext = ( {
487
+ children,
488
+ disableAutoScroll,
489
+ } : DragDropContextProps ) => {
477
490
const { status } = useAppContext ( ) ;
478
491
479
492
if ( status === "LOADING" ) {
480
493
return children ;
481
494
}
482
495
483
- return < DragDropContextClient > { children } </ DragDropContextClient > ;
496
+ return (
497
+ < DragDropContextClient disableAutoScroll = { disableAutoScroll } >
498
+ { children }
499
+ </ DragDropContextClient >
500
+ ) ;
484
501
} ;
0 commit comments