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