File tree Expand file tree Collapse file tree 4 files changed +10
-0
lines changed
apps/demo/app/custom-ui/[...puckPath] Expand file tree Collapse file tree 4 files changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -68,6 +68,12 @@ const Tabs = ({
68
68
currentTabRef . current = currentTab ;
69
69
} , [ currentTab ] ) ;
70
70
71
+ useEffect ( ( ) => {
72
+ if ( appState . ui . isDragging && currentTab === 1 ) {
73
+ setCurrentTab ( - 1 ) ;
74
+ }
75
+ } , [ currentTab , appState . ui . isDragging ] ) ;
76
+
71
77
return (
72
78
< div
73
79
onClick = { ( e ) => e . stopPropagation ( ) }
Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ export const defaultAppState: AppState = {
13
13
arrayState : { } ,
14
14
itemSelector : null ,
15
15
componentList : { } ,
16
+ isDragging : false ,
16
17
} ,
17
18
} ;
18
19
Original file line number Diff line number Diff line change @@ -300,9 +300,11 @@ export function Puck({
300
300
onBeforeDragStart = { ( start ) => {
301
301
onDragStartOrUpdate ( start ) ;
302
302
setItemSelector ( null ) ;
303
+ dispatch ( { type : "setUi" , ui : { isDragging : true } } ) ;
303
304
} }
304
305
onDragEnd = { ( droppedItem ) => {
305
306
setDraggedItem ( undefined ) ;
307
+ dispatch ( { type : "setUi" , ui : { isDragging : false } } ) ;
306
308
307
309
// User cancel drag
308
310
if ( ! droppedItem . destination ) {
Original file line number Diff line number Diff line change @@ -261,6 +261,7 @@ export type UiState = {
261
261
expanded ?: boolean ;
262
262
}
263
263
> ;
264
+ isDragging : boolean ;
264
265
} ;
265
266
266
267
export type AppState = { data : Data ; ui : UiState } ;
You can’t perform that action at this time.
0 commit comments