Allow dropping on empty space below tree

This commit is contained in:
Andrew Kingston 2022-08-30 13:32:52 +01:00
parent 7dc29140ca
commit d445aadbcf
2 changed files with 19 additions and 2 deletions

View File

@ -1,5 +1,7 @@
<script> <script>
import { setContext } from "svelte" import { setContext } from "svelte"
import { dndStore } from "./dndStore"
import { notifications } from "@budibase/bbui"
let scrollRef let scrollRef
@ -50,9 +52,23 @@
setContext("scroll", { setContext("scroll", {
scrollTo, scrollTo,
}) })
const onDrop = async () => {
try {
await dndStore.actions.drop()
} catch (error) {
console.error(error)
notifications.error("Error saving component")
}
}
</script> </script>
<div bind:this={scrollRef}> <div
bind:this={scrollRef}
on:drop={onDrop}
ondragover="return false"
ondragenter="return false"
>
<slot /> <slot />
</div> </div>

View File

@ -68,7 +68,8 @@
closedNodes = closedNodes closedNodes = closedNodes
} }
const onDrop = async () => { const onDrop = async e => {
e.stopPropagation()
try { try {
await dndStore.actions.drop() await dndStore.actions.drop()
} catch (error) { } catch (error) {