Fix same svelte-dnd-action drag error for navigation editor

This commit is contained in:
Andrew Kingston 2021-07-26 14:11:30 +01:00
parent 3d21286aaf
commit 083d05f389
1 changed files with 20 additions and 3 deletions

View File

@ -15,13 +15,13 @@
export let links = []
const flipDurationMs = 150
let dragDisabled = true
$: links.forEach(link => {
if (!link.id) {
link.id = generate()
}
})
$: urlOptions = $store.screens
.map(screen => screen.routing?.route)
.filter(x => x != null)
@ -37,6 +37,11 @@
const updateLinks = e => {
links = e.detail.items
}
const handleFinalize = e => {
updateLinks(e)
dragDisabled = true
}
</script>
<DrawerContent>
@ -49,13 +54,21 @@
items: links,
flipDurationMs,
dropTargetStyle: { outline: "none" },
dragDisabled,
}}
on:finalize={updateLinks}
on:finalize={handleFinalize}
on:consider={updateLinks}
>
{#each links as link (link.id)}
<div class="link" animate:flip={{ duration: flipDurationMs }}>
<Icon name="DragHandle" size="XL" />
<div
class="handle"
aria-label="drag-handle"
style={dragDisabled ? "cursor: grab" : "cursor: grabbing"}
on:mousedown={() => (dragDisabled = false)}
>
<Icon name="DragHandle" size="XL" />
</div>
<Input bind:value={link.text} placeholder="Text" />
<Combobox
bind:value={link.url}
@ -108,4 +121,8 @@
flex: 1 1 auto;
width: 0;
}
.handle {
display: grid;
place-items: center;
}
</style>