diff --git a/apps/demo/app/custom-ui/[...puckPath]/client.tsx b/apps/demo/app/custom-ui/[...puckPath]/client.tsx
index bc8c5b080c..d07080a429 100644
--- a/apps/demo/app/custom-ui/[...puckPath]/client.tsx
+++ b/apps/demo/app/custom-ui/[...puckPath]/client.tsx
@@ -68,6 +68,12 @@ const Tabs = ({
currentTabRef.current = currentTab;
}, [currentTab]);
+ useEffect(() => {
+ if (appState.ui.isDragging && currentTab === 1) {
+ setCurrentTab(-1);
+ }
+ }, [currentTab, appState.ui.isDragging]);
+
return (
e.stopPropagation()}
diff --git a/packages/core/components/Puck/context.tsx b/packages/core/components/Puck/context.tsx
index 91540fb9fa..4355921bff 100644
--- a/packages/core/components/Puck/context.tsx
+++ b/packages/core/components/Puck/context.tsx
@@ -13,6 +13,7 @@ export const defaultAppState: AppState = {
arrayState: {},
itemSelector: null,
componentList: {},
+ isDragging: false,
},
};
diff --git a/packages/core/components/Puck/index.tsx b/packages/core/components/Puck/index.tsx
index 1ffbb0b449..69557a2788 100644
--- a/packages/core/components/Puck/index.tsx
+++ b/packages/core/components/Puck/index.tsx
@@ -300,9 +300,11 @@ export function Puck({
onBeforeDragStart={(start) => {
onDragStartOrUpdate(start);
setItemSelector(null);
+ dispatch({ type: "setUi", ui: { isDragging: true } });
}}
onDragEnd={(droppedItem) => {
setDraggedItem(undefined);
+ dispatch({ type: "setUi", ui: { isDragging: false } });
// User cancel drag
if (!droppedItem.destination) {
diff --git a/packages/core/types/Config.tsx b/packages/core/types/Config.tsx
index b5407408fa..4aabb95c0e 100644
--- a/packages/core/types/Config.tsx
+++ b/packages/core/types/Config.tsx
@@ -261,6 +261,7 @@ export type UiState = {
expanded?: boolean;
}
>;
+ isDragging: boolean;
};
export type AppState = { data: Data; ui: UiState };