Fix svelte-dnd-action throwing an error when interacting with a spectrum field inside a draggable
This commit is contained in:
parent
caccba8fd8
commit
3d21286aaf
|
@ -54,6 +54,7 @@
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
|
let dragDisabled = true
|
||||||
$: definition = store.actions.components.getDefinition(
|
$: definition = store.actions.components.getDefinition(
|
||||||
$selectedComponent?._component
|
$selectedComponent?._component
|
||||||
)
|
)
|
||||||
|
@ -96,11 +97,16 @@
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
const removeLink = id => {
|
const removeCondition = id => {
|
||||||
conditions = conditions.filter(link => link.id !== id)
|
conditions = conditions.filter(link => link.id !== id)
|
||||||
}
|
}
|
||||||
|
|
||||||
const updateLinks = e => {
|
const handleFinalize = e => {
|
||||||
|
updateConditions(e)
|
||||||
|
dragDisabled = true
|
||||||
|
}
|
||||||
|
|
||||||
|
const updateConditions = e => {
|
||||||
conditions = e.detail.items
|
conditions = e.detail.items
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -142,19 +148,26 @@
|
||||||
items: conditions,
|
items: conditions,
|
||||||
flipDurationMs,
|
flipDurationMs,
|
||||||
dropTargetStyle: { outline: "none" },
|
dropTargetStyle: { outline: "none" },
|
||||||
|
dragDisabled,
|
||||||
}}
|
}}
|
||||||
on:finalize={updateLinks}
|
on:finalize={handleFinalize}
|
||||||
on:consider={updateLinks}
|
on:consider={updateConditions}
|
||||||
>
|
>
|
||||||
{#each conditions as condition (condition.id)}
|
{#each conditions as condition (condition.id)}
|
||||||
<div
|
<div
|
||||||
class="condition"
|
class="condition"
|
||||||
class:update={condition.action === "update"}
|
class:update={condition.action === "update"}
|
||||||
animate:flip={{ duration: flipDurationMs }}
|
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>
|
||||||
<Select
|
<Select
|
||||||
draggable={false}
|
|
||||||
placeholder={null}
|
placeholder={null}
|
||||||
options={actionOptions}
|
options={actionOptions}
|
||||||
bind:value={condition.action}
|
bind:value={condition.action}
|
||||||
|
@ -226,7 +239,7 @@
|
||||||
name="Close"
|
name="Close"
|
||||||
hoverable
|
hoverable
|
||||||
size="S"
|
size="S"
|
||||||
on:click={() => removeLink(condition.id)}
|
on:click={() => removeCondition(condition.id)}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
{/each}
|
{/each}
|
||||||
|
@ -270,4 +283,8 @@
|
||||||
.condition:hover {
|
.condition:hover {
|
||||||
background-color: var(--spectrum-global-color-gray-100);
|
background-color: var(--spectrum-global-color-gray-100);
|
||||||
}
|
}
|
||||||
|
.handle {
|
||||||
|
display: grid;
|
||||||
|
place-items: center;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
Loading…
Reference in New Issue