mirror of
https://github.com/simstudioai/sim.git
synced 2026-09-24 15:45:35 +08:00
Fixed edge re-render on handle port toggle
This commit is contained in:
@@ -19,7 +19,7 @@ export function ActionBar({ blockId }: ActionBarProps) {
|
||||
)
|
||||
|
||||
return (
|
||||
<div className="absolute top-0 -right-20 flex flex-col items-center gap-2 p-2 bg-white rounded-md shadow-sm border border-gray-200 animate-in fade-in slide-in-from-left-2">
|
||||
<div className="absolute top-0 -right-20 flex flex-col items-center gap-2 p-2 bg-white rounded-md shadow-sm border border-gray-200">
|
||||
<Tooltip>
|
||||
<TooltipTrigger asChild>
|
||||
<Button
|
||||
|
||||
@@ -19,11 +19,6 @@ interface WorkflowBlockProps {
|
||||
selected?: boolean
|
||||
}
|
||||
|
||||
interface SubBlockPosition {
|
||||
id: string
|
||||
top: number
|
||||
}
|
||||
|
||||
export function WorkflowBlock({ id, type, config, name, selected }: WorkflowBlockProps) {
|
||||
const { toolbar, workflow } = config
|
||||
const [isConnecting, setIsConnecting] = useState(false)
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import { useEffect, useState } from 'react'
|
||||
import { NodeProps } from 'reactflow'
|
||||
import { useWorkflowStore } from '@/stores/workflow/store'
|
||||
import { BlockConfig } from '../../../../../blocks/types'
|
||||
import { WorkflowBlock } from '../workflow-block/workflow-block'
|
||||
|
||||
@@ -8,13 +10,26 @@ interface WorkflowNodeData {
|
||||
name: string
|
||||
}
|
||||
|
||||
export const WorkflowNode = ({ data, id, xPos, yPos, selected }: NodeProps<WorkflowNodeData>) => (
|
||||
<WorkflowBlock
|
||||
id={id}
|
||||
type={data.type}
|
||||
position={{ x: xPos, y: yPos }}
|
||||
config={data.config}
|
||||
name={data.name}
|
||||
selected={selected}
|
||||
/>
|
||||
)
|
||||
export const WorkflowNode = ({ data, id, xPos, yPos, selected }: NodeProps<WorkflowNodeData>) => {
|
||||
const [key, setKey] = useState(0)
|
||||
const horizontalHandles = useWorkflowStore(
|
||||
(state) => state.blocks[id]?.horizontalHandles ?? false
|
||||
)
|
||||
|
||||
// Add effect to trigger immediate re-render after handle toggle
|
||||
useEffect(() => {
|
||||
setKey((prev) => prev + 1)
|
||||
}, [horizontalHandles])
|
||||
|
||||
return (
|
||||
<WorkflowBlock
|
||||
key={key}
|
||||
id={id}
|
||||
type={data.type}
|
||||
position={{ x: xPos, y: yPos }}
|
||||
config={data.config}
|
||||
name={data.name}
|
||||
selected={selected}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user