diff --git a/frontend/src/lib/components/apps/editor/component/ComponentNavigation.svelte b/frontend/src/lib/components/apps/editor/component/ComponentNavigation.svelte
index 75816cd942..760deec2d9 100644
--- a/frontend/src/lib/components/apps/editor/component/ComponentNavigation.svelte
+++ b/frontend/src/lib/components/apps/editor/component/ComponentNavigation.svelte
@@ -6,7 +6,7 @@
getAllSubgridsAndComponentIds,
insertNewGridItem
} from '../appUtils'
- import type { AppEditorContext, AppViewerContext, GridItem } from '../../types'
+ import type { AppEditorContext, AppViewerContext, FocusedGrid, GridItem } from '../../types'
import { push } from '$lib/history'
import { sendUserToast } from '$lib/utils'
import { gridColumns } from '../../gridUtils'
@@ -197,14 +197,8 @@
} else if (copiedGridItems) {
let nitems: string[] = []
for (let copiedGridItem of copiedGridItems) {
- nitems.push(
- insertNewGridItem(
- $app,
- (id) => ({ ...copiedGridItem.data, id }),
- $focusedGrid,
- Object.fromEntries(gridColumns.map((column) => [column, copiedGridItem[column]]))
- )
- )
+ let newItem = copyComponent(copiedGridItem, $focusedGrid)
+ newItem && nitems.push(newItem)
}
$selectedComponent = nitems.map((x) => x)
}
@@ -212,6 +206,31 @@
$app = $app
}
+ function copyComponent(item: GridItem, parentGrid: FocusedGrid | undefined, doNotVisit?: string) {
+ if (item.id === doNotVisit) {
+ return
+ }
+ const newItem = insertNewGridItem(
+ $app,
+ (id) => ({ ...item.data, id }),
+ parentGrid,
+ Object.fromEntries(gridColumns.map((column) => [column, item[column]]))
+ )
+
+ if ($app.subgrids && item.data.numberOfSubgrids) {
+ for (let i = 0; i < item.data.numberOfSubgrids; i++) {
+ $app.subgrids[`${item.id}-${i}`].forEach((subgridItem) => {
+ copyComponent(
+ subgridItem,
+ { parentComponentId: newItem, subGridIndex: i },
+ doNotVisit ?? newItem
+ )
+ })
+ }
+ }
+ return newItem
+ }
+
function keydown(event: KeyboardEvent) {
// Ignore keydown events if the user is typing in monaco
let classes = event.target?.['className']
diff --git a/frontend/src/routes/(root)/(logged)/flows/get/[...path]/+page.svelte b/frontend/src/routes/(root)/(logged)/flows/get/[...path]/+page.svelte
index 3fd65ab3ec..8f86b1b509 100644
--- a/frontend/src/routes/(root)/(logged)/flows/get/[...path]/+page.svelte
+++ b/frontend/src/routes/(root)/(logged)/flows/get/[...path]/+page.svelte
@@ -314,7 +314,7 @@