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