Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions frontend/src/lib/components/SchemaForm.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@
import ArgInput from './ArgInput.svelte'
import { createEventDispatcher, untrack } from 'svelte'
import { deepEqual } from 'fast-equals'
import { dragHandleZone, type Options as DndOptions } from '@windmill-labs/svelte-dnd-action'
import {
dragHandleZone,
SHADOW_ITEM_MARKER_PROPERTY_NAME,
type Options as DndOptions
} from '@windmill-labs/svelte-dnd-action'
import type { SchemaDiff } from '$lib/components/schema/schemaUtils.svelte'
import type { ComponentCustomCSS } from './apps/types'
import ResizeTransitionWrapper from './common/ResizeTransitionWrapper.svelte'
Expand Down Expand Up @@ -295,7 +299,9 @@
class={twMerge(
typeof diff[argName] === 'object' &&
diff[argName].diff !== 'same' &&
'bg-red-300 dark:bg-red-800 rounded-md'
'bg-red-300 dark:bg-red-800 rounded-md',
item[SHADOW_ITEM_MARKER_PROPERTY_NAME] &&
'!visible border-2 border-dashed border-blue-300 dark:border-blue-600 bg-blue-50 dark:bg-blue-900/20 rounded-md [&>*]:invisible'
)}
innerClass="w-full"
>
Expand Down
22 changes: 19 additions & 3 deletions frontend/src/lib/components/schema/SchemaFormDND.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script lang="ts">
import { createEventDispatcher, untrack } from 'svelte'
import { dragHandle } from '@windmill-labs/svelte-dnd-action'
import { dragHandle, TRIGGERS } from '@windmill-labs/svelte-dnd-action'
import SchemaForm from '../SchemaForm.svelte'
import { GripVertical } from 'lucide-svelte'
import type { Schema } from '$lib/common'
Expand Down Expand Up @@ -79,9 +79,24 @@
}
}

let dragStartTime = 0
const DRAG_GRACE_PERIOD_MS = 200

function handleConsider(e) {
dragDisabledState = false
const { items: newItems } = e.detail
const { items: newItems, info } = e.detail

if (info.trigger === TRIGGERS.DRAG_STARTED) {
dragStartTime = Date.now()
items = $state.snapshot(newItems)
return
}

// Ignore reorders during grace period so small movements don't cause jumps
if (Date.now() - dragStartTime < DRAG_GRACE_PERIOD_MS) {
return
}

items = $state.snapshot(newItems)
}

Expand Down Expand Up @@ -130,7 +145,8 @@
items,
flipDurationMs,
dropTargetStyle: {},
type: dndType
type: dndType,
morphDisabled: true
}}
{items}
{diff}
Expand Down
Loading