1- import { DragDropContext , OnDragEndResponder } from '@hello-pangea/dnd' ;
1+ import { DragDropContext , OnDragEndResponder , OnDragStartResponder } from '@hello-pangea/dnd' ;
22import { Box } from '@mui/material' ;
33import { useCallback , useRef , useState } from 'react' ;
44import { Project , Task , TaskWithIndex } from 'shared' ;
@@ -22,6 +22,7 @@ export const TaskListContent = ({ project }: TaskListProps) => {
2222 // ref to mapping of each column's status to its measured height, partial because heights may not exist
2323 const columnHeightsRef = useRef < Partial < Record < Task [ 'status' ] , number > > > ( { } ) ;
2424 const [ equalizedHeight , setEqualizedHeight ] = useState ( 0 ) ;
25+ const [ isDragging , setIsDragging ] = useState ( false ) ;
2526
2627 const onHeightChange = useCallback ( ( status : Task [ 'status' ] , height : number ) => {
2728 columnHeightsRef . current [ status ] = height ;
@@ -64,7 +65,12 @@ export const TaskListContent = ({ project }: TaskListProps) => {
6465 } ) ) ;
6566 } ;
6667
68+ const onDragStart : OnDragStartResponder = ( ) => {
69+ setIsDragging ( true ) ;
70+ }
71+
6772 const onDragEnd : OnDragEndResponder = async ( result ) => {
73+ setIsDragging ( false ) ;
6874 const { destination, source } = result ;
6975
7076 if ( ! destination ) {
@@ -120,7 +126,7 @@ export const TaskListContent = ({ project }: TaskListProps) => {
120126 } ;
121127
122128 return (
123- < DragDropContext onDragEnd = { onDragEnd } >
129+ < DragDropContext onDragStart = { onDragStart } onDragEnd = { onDragEnd } >
124130 < Box display = "flex" >
125131 { statuses . map ( ( status ) => (
126132 < TaskColumn
@@ -133,6 +139,7 @@ export const TaskListContent = ({ project }: TaskListProps) => {
133139 key = { status }
134140 project = { project }
135141 equalizedHeight = { equalizedHeight }
142+ isDragging = { isDragging }
136143 />
137144 ) ) }
138145 </ Box >
0 commit comments