Skip to content

Commit 48a8952

Browse files
committed
improvement(ux): action bar hover and cursor ref on click in prod
1 parent 892b297 commit 48a8952

File tree

3 files changed

+19
-20
lines changed

3 files changed

+19
-20
lines changed

app/w/[id]/components/workflow-block/components/action-bar/action-bar.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,14 @@ export function ActionBar({ blockId, blockType }: ActionBarProps) {
2222
const isStarterBlock = blockType === 'starter'
2323

2424
return (
25-
<div className="absolute top-0 -right-20 flex flex-col items-center gap-2 p-2 bg-background rounded-md shadow-sm border border-gray-200 dark:border-gray-800">
25+
<div
26+
className={cn(
27+
'absolute top-0 -right-20',
28+
'flex flex-col items-center gap-2 p-2',
29+
'bg-background rounded-md shadow-sm border border-gray-200 dark:border-gray-800',
30+
'opacity-0 group-hover:opacity-100 transition-opacity duration-200'
31+
)}
32+
>
2633
{/* <Tooltip>
2734
<TooltipTrigger asChild>
2835
<Button

app/w/[id]/components/workflow-block/workflow-block.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ interface WorkflowBlockProps {
2121
}
2222

2323
// Combine both interfaces into a single component
24-
export function WorkflowBlock({ id, data, selected }: NodeProps<WorkflowBlockProps>) {
24+
export function WorkflowBlock({ id, data }: NodeProps<WorkflowBlockProps>) {
25+
console.log('Rendering WorkflowBlock', id)
2526
const { type, config, name } = data
2627

2728
// State management
@@ -50,7 +51,6 @@ export function WorkflowBlock({ id, data, selected }: NodeProps<WorkflowBlockPro
5051

5152
// Execution store
5253
const isActiveBlock = useExecutionStore((state) => state.activeBlockIds.has(id))
53-
// const isExecuting = useExecutionStore((state) => state.isExecuting)
5454

5555
// Update node internals when handles change
5656
useEffect(() => {
@@ -180,18 +180,18 @@ export function WorkflowBlock({ id, data, selected }: NodeProps<WorkflowBlockPro
180180
}
181181

182182
return (
183-
<div className="relative">
183+
<div className="relative group">
184184
<Card
185185
ref={blockRef}
186186
className={cn(
187-
'shadow-md select-none group relative cursor-default',
187+
'shadow-md select-none relative cursor-default',
188188
'transition-ring transition-block-bg',
189189
isWide ? 'w-[480px]' : 'w-[320px]',
190190
!isEnabled && 'shadow-sm',
191191
isActiveBlock && 'ring-2 animate-pulse-ring'
192192
)}
193193
>
194-
{selected && <ActionBar blockId={id} blockType={type} />}
194+
<ActionBar blockId={id} blockType={type} />
195195
<ConnectionBlocks blockId={id} setIsConnecting={setIsConnecting} />
196196

197197
{/* Input Handle - Don't show for starter blocks */}

app/w/[id]/workflow.tsx

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ const edgeTypes: EdgeTypes = { custom: CustomEdge }
3636

3737
function WorkflowContent() {
3838
// State
39-
const [selectedBlockId, setSelectedBlockId] = useState<string | null>(null)
4039
const [selectedEdgeId, setSelectedEdgeId] = useState<string | null>(null)
4140
const [isInitialized, setIsInitialized] = useState(false)
4241

@@ -143,7 +142,6 @@ function WorkflowContent() {
143142
position,
144143
parentId: parentLoop ? `loop-${parentLoop[0]}` : undefined,
145144
dragHandle: '.workflow-drag-handle',
146-
selected: block.id === selectedBlockId,
147145
data: {
148146
type: block.type,
149147
config: blockConfig,
@@ -153,7 +151,7 @@ function WorkflowContent() {
153151
})
154152

155153
return nodeArray
156-
}, [blocks, loops, selectedBlockId])
154+
}, [blocks, loops])
157155

158156
// Update nodes
159157
const onNodesChange = useCallback(
@@ -277,23 +275,14 @@ function WorkflowContent() {
277275
[project, blocks, addBlock, addEdge, findClosestOutput]
278276
)
279277

280-
// Node selection
281-
const onNodeClick = useCallback((event: React.MouseEvent, node: any) => {
282-
event.stopPropagation()
283-
setSelectedBlockId(node.id)
284-
setSelectedEdgeId(null)
285-
}, [])
286-
287-
// Clear selection
278+
// Update onPaneClick to only handle edge selection
288279
const onPaneClick = useCallback(() => {
289-
setSelectedBlockId(null)
290280
setSelectedEdgeId(null)
291281
}, [])
292282

293283
// Edge selection
294284
const onEdgeClick = useCallback((event: React.MouseEvent, edge: any) => {
295285
setSelectedEdgeId(edge.id)
296-
setSelectedBlockId(null)
297286
}, [])
298287

299288
// Transform edges to include selection state
@@ -354,7 +343,10 @@ function WorkflowContent() {
354343
strokeDasharray: '5,5',
355344
}}
356345
connectionLineType={ConnectionLineType.SmoothStep}
357-
onNodeClick={onNodeClick}
346+
onNodeClick={(e) => {
347+
e.stopPropagation()
348+
e.preventDefault()
349+
}}
358350
onPaneClick={onPaneClick}
359351
onEdgeClick={onEdgeClick}
360352
elementsSelectable={true}

0 commit comments

Comments
 (0)