Fix issues dropping components from new component panel
This commit is contained in:
parent
121eddaa5a
commit
78a5f9c891
|
@ -245,6 +245,7 @@
|
||||||
drop.parent,
|
drop.parent,
|
||||||
drop.index
|
drop.index
|
||||||
)
|
)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convert parent + index into target + mode
|
// Convert parent + index into target + mode
|
||||||
|
|
|
@ -2,10 +2,6 @@ import { writable, derived } from "svelte/store"
|
||||||
|
|
||||||
const createDndStore = () => {
|
const createDndStore = () => {
|
||||||
const initialState = {
|
const initialState = {
|
||||||
// Flags for whether we are inserting a new component or not
|
|
||||||
isNewComponent: false,
|
|
||||||
newComponentType: null,
|
|
||||||
|
|
||||||
// Info about the dragged component
|
// Info about the dragged component
|
||||||
source: null,
|
source: null,
|
||||||
|
|
||||||
|
@ -24,8 +20,8 @@ const createDndStore = () => {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const startDraggingNewComponent = ({ type, definition }) => {
|
const startDraggingNewComponent = ({ component, definition }) => {
|
||||||
if (!type || !definition) {
|
if (!component || !definition) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,13 +31,12 @@ const createDndStore = () => {
|
||||||
|
|
||||||
store.set({
|
store.set({
|
||||||
...initialState,
|
...initialState,
|
||||||
isNewComponent: true,
|
|
||||||
newComponentType: type,
|
|
||||||
source: {
|
source: {
|
||||||
id: null,
|
id: null,
|
||||||
parent: null,
|
parent: null,
|
||||||
bounds: { height, width },
|
bounds: { height, width },
|
||||||
index: null,
|
index: null,
|
||||||
|
newComponentType: component,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -91,5 +86,5 @@ export const dndBounds = derived(
|
||||||
)
|
)
|
||||||
export const dndIsNewComponent = derived(
|
export const dndIsNewComponent = derived(
|
||||||
dndStore,
|
dndStore,
|
||||||
$dndStore => $dndStore.isNewComponent
|
$dndStore => $dndStore.source?.newComponentType != null
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue