@@ -3,7 +3,7 @@ import PropTypes from 'prop-types';
33import {
44 DndContext ,
55 DragOverlay ,
6- closestCorners ,
6+ closestCenter ,
77 KeyboardSensor ,
88 PointerSensor ,
99 useSensor ,
@@ -72,10 +72,12 @@ function Board({
7272
7373 const [ isListAddOpened , setIsListAddOpened ] = useState ( false ) ;
7474
75+ const listsIds = useMemo ( ( ) => listItems . map ( ( list ) => list . id ) , [ listItems ] ) ;
76+
7577 const sensors = useSensors (
7678 useSensor ( PointerSensor , {
7779 activationConstraint : {
78- distance : 5 ,
80+ distance : 1 ,
7981 } ,
8082 } ) ,
8183 useSensor ( KeyboardSensor , {
@@ -107,6 +109,7 @@ function Board({
107109
108110 const handleDragOver = ( event ) => {
109111 const { active, over } = event ;
112+
110113 if ( ! over ) return ;
111114
112115 const draggedId = active . id ;
@@ -134,16 +137,17 @@ function Board({
134137
135138 // Handle list reordering in real-time
136139 if ( isActiveList && isOverList ) {
137- setListItems ( ( currentListItems ) => {
138- const activeIndex = currentListItems . findIndex ( ( col ) => col . id === draggedId ) ;
139- const overIndex = currentListItems . findIndex ( ( col ) => col . id === overId ) ;
140-
141- if ( activeIndex !== - 1 && overIndex !== - 1 && activeIndex !== overIndex ) {
142- return arrayMove ( currentListItems , activeIndex , overIndex ) ;
143- }
144- return currentListItems ;
145- } ) ;
146- return ;
140+ setTimeout ( ( ) => {
141+ setListItems ( ( currentListItems ) => {
142+ const activeIndex = currentListItems . findIndex ( ( col ) => col . id === draggedId ) ;
143+ const overIndex = currentListItems . findIndex ( ( col ) => col . id === overId ) ;
144+
145+ if ( activeIndex !== - 1 && overIndex !== - 1 && activeIndex !== overIndex ) {
146+ return arrayMove ( currentListItems , activeIndex , overIndex ) ;
147+ }
148+ return currentListItems ;
149+ } ) ;
150+ } , 0 ) ;
147151 }
148152
149153 // Skip card logic if dragging a list
@@ -195,6 +199,7 @@ function Board({
195199
196200 const handleDragEnd = ( event ) => {
197201 const { active, over } = event ;
202+
198203 if ( ! over ) {
199204 setActiveId ( null ) ;
200205 return ;
@@ -307,15 +312,12 @@ function Board({
307312 < div className = { styles . wrapper } >
308313 < DndContext
309314 sensors = { sensors }
310- collisionDetection = { closestCorners }
315+ collisionDetection = { closestCenter }
311316 onDragStart = { handleDragStart }
312317 onDragOver = { handleDragOver }
313318 onDragEnd = { handleDragEnd }
314319 >
315- < SortableContext
316- items = { listItems . map ( ( col ) => col . id ) }
317- strategy = { horizontalListSortingStrategy }
318- >
320+ < SortableContext items = { listsIds } strategy = { horizontalListSortingStrategy } >
319321 < div className = { styles . container } >
320322 { listItems . map ( ( list ) => (
321323 < List
0 commit comments