@@ -13,7 +13,15 @@ const DROP_EVENT = 'drop';
1313/**
1414 * @param dropZone – ref to the dropZone component
1515 */
16- const useDragAndDrop : UseDragAndDrop = ( { dropZone, onDrop = ( ) => { } , shouldAllowDrop = true , isDisabled = false , shouldAcceptDrop = ( ) => true } ) => {
16+ const useDragAndDrop : UseDragAndDrop = ( {
17+ dropZone,
18+ onDrop = ( ) => { } ,
19+ shouldAllowDrop = true ,
20+ isDisabled = false ,
21+ shouldAcceptDrop = ( ) => true ,
22+ shouldHandleDragEvent = true ,
23+ shouldStopPropagation = true ,
24+ } ) => {
1725 const isFocused = useIsFocused ( ) ;
1826 const [ isDraggingOver , setIsDraggingOver ] = useState ( false ) ;
1927 const { close : closePopover } = useContext ( PopoverContext ) ;
@@ -29,6 +37,10 @@ const useDragAndDrop: UseDragAndDrop = ({dropZone, onDrop = () => {}, shouldAllo
2937
3038 const handleDragEvent = useCallback (
3139 ( event : DragEvent ) => {
40+ if ( ! shouldHandleDragEvent ) {
41+ return ;
42+ }
43+
3244 const shouldAcceptThisDrop = shouldAllowDrop && shouldAcceptDrop ( event ) ;
3345
3446 if ( shouldAcceptThisDrop && event . type === DRAG_ENTER_EVENT ) {
@@ -44,7 +56,7 @@ const useDragAndDrop: UseDragAndDrop = ({dropZone, onDrop = () => {}, shouldAllo
4456 event . dataTransfer . effectAllowed = effect ;
4557 }
4658 } ,
47- [ shouldAllowDrop , shouldAcceptDrop , closePopover ] ,
59+ [ shouldHandleDragEvent , shouldAllowDrop , shouldAcceptDrop , closePopover ] ,
4860 ) ;
4961
5062 /**
@@ -57,7 +69,9 @@ const useDragAndDrop: UseDragAndDrop = ({dropZone, onDrop = () => {}, shouldAllo
5769 }
5870
5971 event . preventDefault ( ) ;
60- event . stopPropagation ( ) ;
72+ if ( shouldStopPropagation ) {
73+ event . stopPropagation ( ) ;
74+ }
6175
6276 switch ( event . type ) {
6377 case DRAG_OVER_EVENT :
@@ -90,7 +104,7 @@ const useDragAndDrop: UseDragAndDrop = ({dropZone, onDrop = () => {}, shouldAllo
90104 break ;
91105 }
92106 } ,
93- [ isFocused , isDisabled , shouldAcceptDrop , isDraggingOver , onDrop , handleDragEvent ] ,
107+ [ isFocused , isDisabled , shouldAcceptDrop , shouldStopPropagation , handleDragEvent , isDraggingOver , onDrop ] ,
94108 ) ;
95109
96110 useEffect ( ( ) => {
0 commit comments