[ENG-1546] Relation creation via drag handles (Roam)#923
Conversation
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
1565d15 to
e46db0a
Compare
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Matches the Obsidian (eng-1547) pattern: padding is now applied after pageToViewport conversion so dots remain a fixed screen distance from the node edge regardless of zoom level. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
- Show complement label when creating relation in reverse direction - DRY checkConnectionType into canvasUtils (used by RelationUtil + overlays) - Remove labelColor override to match DiscourseRelationTool convention Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
842d51d to
612a8f9
Compare
| const sourceNode = editor.getShape(pending.sourceId); | ||
| const targetNode = editor.getShape(pending.targetId); | ||
| const { isReverse } = checkConnectionType( | ||
| selectedRelation, | ||
| sourceNode?.type ?? "", | ||
| targetNode?.type ?? "", | ||
| ); |
There was a problem hiding this comment.
If either the source or target node is deleted between the drop and relation type selection, sourceNode or targetNode will be null/undefined. The code uses nullish coalescing to default to empty strings (sourceNode?.type ?? ""), but doesn't validate that both nodes still exist before proceeding.
This will cause checkConnectionType to return { isDirect: false, isReverse: false } for empty string types, potentially creating the relation with the wrong label (using primary label instead of complement).
Fix: Add validation after getting the shapes:
const sourceNode = editor.getShape(pending.sourceId);
const targetNode = editor.getShape(pending.targetId);
if (!sourceNode || !targetNode || !isDiscourseNodeShape(editor, sourceNode) || !isDiscourseNodeShape(editor, targetNode)) {
setPending(null);
sourceNodeRef.current = null;
return;
}
const { isReverse } = checkConnectionType(
selectedRelation,
sourceNode.type,
targetNode.type,
);| const sourceNode = editor.getShape(pending.sourceId); | |
| const targetNode = editor.getShape(pending.targetId); | |
| const { isReverse } = checkConnectionType( | |
| selectedRelation, | |
| sourceNode?.type ?? "", | |
| targetNode?.type ?? "", | |
| ); | |
| const sourceNode = editor.getShape(pending.sourceId); | |
| const targetNode = editor.getShape(pending.targetId); | |
| if ( | |
| !sourceNode || | |
| !targetNode || | |
| !isDiscourseNodeShape(editor, sourceNode) || | |
| !isDiscourseNodeShape(editor, targetNode) | |
| ) { | |
| setPending(null); | |
| sourceNodeRef.current = null; | |
| return; | |
| } | |
| const { isReverse } = checkConnectionType( | |
| selectedRelation, | |
| sourceNode.type, | |
| targetNode.type, | |
| ); | |
Spotted by Graphite
Is this helpful? React 👍 or 👎 to let us know.
https://www.loom.com/share/253732c148ca4cb39907c564e6b53e77
Summary
handleCreateRelationsInRoam(supports both stored/reified relations and legacy triple-based approach)Test plan
🤖 Generated with Claude Code