1
0
Fork 0
mirror of synced 2024-07-03 13:30:46 +12:00

Prevent DND if target is a child of source

This commit is contained in:
Andrew Kingston 2021-09-16 07:35:19 +01:00
parent 0ce0f5c823
commit d86e5718d5

View file

@ -8,7 +8,7 @@
import ConfirmDialog from "components/common/ConfirmDialog.svelte"
import { ProgressCircle, Layout, Heading, Body } from "@budibase/bbui"
import ErrorSVG from "assets/error.svg?raw"
import { findComponent } from "builderStore/storeUtils"
import { findComponent, findComponentPath } from "builderStore/storeUtils"
let iframe
let layout
@ -123,6 +123,17 @@
get(currentAsset).props,
data.destinationComponentId
)
// Stop if the target is a child of source
const path = findComponentPath(
sourceComponent,
data.destinationComponentId
)
const ids = path.map(component => component._id)
if (ids.includes(data.destinationComponentId)) {
return
}
if (sourceComponent && destinationComponent) {
store.actions.components.copy(sourceComponent, true)
store.actions.components.paste(destinationComponent, data.mode)