Skip to content

Commit fd7f0d3

Browse files
rubenfiszelclaude
andauthored
fix: improve DND drag feedback in EditableSchemaForm (#8449)
Three issues fixed: - Dragged element clone was invisible because morphDraggedElementToBeLike ran before the clone was in the DOM, copying 0-height from the uninitialized ResizeTransitionWrapper shadow. Fixed with morphDisabled. - Shadow placeholder was inconsistently hidden because the DND library's inline visibility:hidden was overwritten by RTW's reactive style binding. Fixed with !visible CSS class that overrides inline styles. - Small cursor movements immediately triggered field reordering. Added a 200ms grace period after drag start before processing reorder events. The shadow element now shows a dashed blue drop-target indicator instead of being fully hidden. Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 7de98c0 commit fd7f0d3

File tree

2 files changed

+27
-5
lines changed

2 files changed

+27
-5
lines changed

frontend/src/lib/components/SchemaForm.svelte

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@
1616
import ArgInput from './ArgInput.svelte'
1717
import { createEventDispatcher, untrack } from 'svelte'
1818
import { deepEqual } from 'fast-equals'
19-
import { dragHandleZone, type Options as DndOptions } from '@windmill-labs/svelte-dnd-action'
19+
import {
20+
dragHandleZone,
21+
SHADOW_ITEM_MARKER_PROPERTY_NAME,
22+
type Options as DndOptions
23+
} from '@windmill-labs/svelte-dnd-action'
2024
import type { SchemaDiff } from '$lib/components/schema/schemaUtils.svelte'
2125
import type { ComponentCustomCSS } from './apps/types'
2226
import ResizeTransitionWrapper from './common/ResizeTransitionWrapper.svelte'
@@ -295,7 +299,9 @@
295299
class={twMerge(
296300
typeof diff[argName] === 'object' &&
297301
diff[argName].diff !== 'same' &&
298-
'bg-red-300 dark:bg-red-800 rounded-md'
302+
'bg-red-300 dark:bg-red-800 rounded-md',
303+
item[SHADOW_ITEM_MARKER_PROPERTY_NAME] &&
304+
'!visible border-2 border-dashed border-blue-300 dark:border-blue-600 bg-blue-50 dark:bg-blue-900/20 rounded-md [&>*]:invisible'
299305
)}
300306
innerClass="w-full"
301307
>

frontend/src/lib/components/schema/SchemaFormDND.svelte

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<script lang="ts">
22
import { createEventDispatcher, untrack } from 'svelte'
3-
import { dragHandle } from '@windmill-labs/svelte-dnd-action'
3+
import { dragHandle, TRIGGERS } from '@windmill-labs/svelte-dnd-action'
44
import SchemaForm from '../SchemaForm.svelte'
55
import { GripVertical } from 'lucide-svelte'
66
import type { Schema } from '$lib/common'
@@ -79,9 +79,24 @@
7979
}
8080
}
8181
82+
let dragStartTime = 0
83+
const DRAG_GRACE_PERIOD_MS = 200
84+
8285
function handleConsider(e) {
8386
dragDisabledState = false
84-
const { items: newItems } = e.detail
87+
const { items: newItems, info } = e.detail
88+
89+
if (info.trigger === TRIGGERS.DRAG_STARTED) {
90+
dragStartTime = Date.now()
91+
items = $state.snapshot(newItems)
92+
return
93+
}
94+
95+
// Ignore reorders during grace period so small movements don't cause jumps
96+
if (Date.now() - dragStartTime < DRAG_GRACE_PERIOD_MS) {
97+
return
98+
}
99+
85100
items = $state.snapshot(newItems)
86101
}
87102
@@ -130,7 +145,8 @@
130145
items,
131146
flipDurationMs,
132147
dropTargetStyle: {},
133-
type: dndType
148+
type: dndType,
149+
morphDisabled: true
134150
}}
135151
{items}
136152
{diff}

0 commit comments

Comments
 (0)