Skip to content

Commit 6045277

Browse files
committed
fix(tag-drop): add drag highlight and onDragLeave to Code.Container
1 parent 9181e93 commit 6045277

File tree

2 files changed

+19
-3
lines changed
  • apps/sim
    • app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/variables-input
    • components/emcn/components/code

2 files changed

+19
-3
lines changed

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/variables-input/variables-input.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,7 @@ export function VariablesInput({
340340
const handleEditorDrop = (e: React.DragEvent, assignmentId: string) => {
341341
if (isReadOnly) return
342342
e.preventDefault()
343+
setDragHighlight((prev) => ({ ...prev, [assignmentId]: false }))
343344
try {
344345
const data = JSON.parse(e.dataTransfer.getData('application/json'))
345346
if (data.type !== 'connectionBlock') return
@@ -506,9 +507,14 @@ export function VariablesInput({
506507

507508
return (
508509
<Code.Container
509-
className='min-h-[120px]'
510-
onDragOver={(e) => e.preventDefault()}
510+
className={cn(
511+
'min-h-[120px]',
512+
dragHighlight[assignment.id] &&
513+
'ring-2 ring-blue-500 ring-offset-2'
514+
)}
515+
onDragOver={(e) => handleDragOver(e, assignment.id)}
511516
onDrop={(e) => handleEditorDrop(e, assignment.id)}
517+
onDragLeave={(e) => handleDragLeave(e, assignment.id)}
512518
>
513519
<Code.Gutter width={gutterWidth}>
514520
{Array.from({ length: lineCount }, (_, i) => (

apps/sim/components/emcn/components/code/code.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,8 @@ interface CodeContainerProps {
356356
onDragOver?: (e: React.DragEvent) => void
357357
/** Drop handler */
358358
onDrop?: (e: React.DragEvent) => void
359+
/** Drag leave handler */
360+
onDragLeave?: (e: React.DragEvent) => void
359361
}
360362

361363
/**
@@ -371,7 +373,14 @@ interface CodeContainerProps {
371373
* </Code.Container>
372374
* ```
373375
*/
374-
function Container({ children, className, style, onDragOver, onDrop }: CodeContainerProps) {
376+
function Container({
377+
children,
378+
className,
379+
style,
380+
onDragOver,
381+
onDrop,
382+
onDragLeave,
383+
}: CodeContainerProps) {
375384
return (
376385
<div
377386
className={cn(
@@ -386,6 +395,7 @@ function Container({ children, className, style, onDragOver, onDrop }: CodeConta
386395
style={style}
387396
onDragOver={onDragOver}
388397
onDrop={onDrop}
398+
onDragLeave={onDragLeave}
389399
>
390400
{children}
391401
</div>

0 commit comments

Comments
 (0)