Compare commits

...

4 Commits

Author SHA1 Message Date
Gustavo Henrique Santos Souza de Miranda e02d736f2e chore: mark US-029 as complete and update progress log
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-21 17:21:52 -03:00
Gustavo Henrique Santos Souza de Miranda 4c7a289714 feat: [US-029] - Select and delete edges
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-21 17:21:27 -03:00
Gustavo Henrique Santos Souza de Miranda ccd88b39d1 chore: mark US-028 as complete and update progress log
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-21 17:19:05 -03:00
Gustavo Henrique Santos Souza de Miranda 82d437eb0c feat: [US-028] - Select and delete nodes
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-21 17:18:27 -03:00
3 changed files with 35 additions and 2 deletions

View File

@ -499,7 +499,7 @@
"Verify in browser using dev-browser skill"
],
"priority": 28,
"passes": false,
"passes": true,
"notes": ""
},
{
@ -514,7 +514,7 @@
"Verify in browser using dev-browser skill"
],
"priority": 29,
"passes": false,
"passes": true,
"notes": ""
},
{

View File

@ -409,3 +409,27 @@
- Apply consistent edge styling in both onConnect (new edges) and toReactFlowEdges (loaded edges)
- Generate unique edge IDs with nanoid in onConnect callback
---
## 2026-01-21 - US-028
- What was implemented: Select and delete nodes functionality
- Files changed:
- src/app/editor/[projectId]/FlowchartEditor.tsx - added deleteKeyCode prop to enable Delete/Backspace key deletion
- **Learnings for future iterations:**
- React Flow has built-in node selection via clicking - no extra configuration needed
- Use `deleteKeyCode={['Delete', 'Backspace']}` prop to enable keyboard deletion
- React Flow automatically removes connected edges when a node is deleted (no manual cleanup needed)
- The useNodesState/useEdgesState hooks with onNodesChange/onEdgesChange handle all deletion state updates
- No explicit onNodesDelete callback is needed - the onNodesChange handler covers deletion events
---
## 2026-01-21 - US-029
- What was implemented: Select and delete edges functionality
- Files changed:
- src/app/editor/[projectId]/FlowchartEditor.tsx - added onEdgesDelete callback
- **Learnings for future iterations:**
- React Flow 11 edges are clickable and selectable by default (interactionWidth renders invisible interaction area)
- The `deleteKeyCode` prop works for both nodes and edges - same configuration covers both
- onEdgesDelete is optional if you just need state management (onEdgesChange handles removal events)
- onEdgesDelete is useful for additional logic like logging, dirty state tracking, or undo/redo
- Edge selection shows visual highlight via React Flow's built-in styling
---

View File

@ -161,6 +161,13 @@ function FlowchartEditorInner({ initialData }: FlowchartEditorProps) {
// TODO: Implement in US-036
}, [])
// Handle edge deletion via keyboard (Delete/Backspace)
const onEdgesDelete = useCallback((deletedEdges: Edge[]) => {
// Edges are already removed from state by onEdgesChange
// This callback can be used for additional logic like logging or dirty state
console.log('Deleted edges:', deletedEdges.map((e) => e.id))
}, [])
return (
<div className="flex h-full w-full flex-col">
<Toolbar
@ -178,7 +185,9 @@ function FlowchartEditorInner({ initialData }: FlowchartEditorProps) {
nodeTypes={nodeTypes}
onNodesChange={onNodesChange}
onEdgesChange={onEdgesChange}
onEdgesDelete={onEdgesDelete}
onConnect={onConnect}
deleteKeyCode={['Delete', 'Backspace']}
fitView
>
<Background variant={BackgroundVariant.Dots} gap={16} size={1} />