Skip to content

Fix: unified frames no longer land stacked on insert#20

Merged
vibhavkatre merged 1 commit into
mainfrom
fix/frame-insert-offset
Jul 20, 2026
Merged

Fix: unified frames no longer land stacked on insert#20
vibhavkatre merged 1 commit into
mainfrom
fix/frame-insert-offset

Conversation

@vibhavkatre

Copy link
Copy Markdown
Collaborator

Problem (found during end-to-end QA)

Creating a new Drawing (unified) diagram and inserting a mind map + a flowchart dropped both frames at the same origin (0,0), so they rendered on top of each other.

Root cause: the home "New diagram" flow builds the doc via createDiagramDocument(undefined, 'unified'), but the distinct frame origins only lived in createUnifiedDocument() — which the create flow never calls.

Fix

Seed the distinct origins (mind map 600,200 · flowchart 600,700) inside createDiagramDocument itself for a unified type, so every unified doc gets separated frames regardless of how it's constructed. createUnifiedDocument now just delegates. Frames remain freely movable.

Tests

  • Added a regression test asserting the plain factory (createDiagramDocument(undefined, 'unified') — the real create-flow path) seeds the distinct origins. The pre-existing test only exercised createUnifiedDocument, which is exactly why the stacking slipped through.
  • vitest run101 pass.

Verified in the running app

Playwright drive against the local bench: create → Insert → Mind map → Insert → Flowchart now shows the two frames spatially separated (before: overlapping). Screenshots captured; 9/9 QA checks green.

🤖 Generated with Claude Code

A new "Drawing" (unified) diagram is created via
createDiagramDocument(undefined, 'unified') from the home "New diagram" flow.
That factory left both auto-layout frames at their model-default origin (0,0), so
inserting a mind map and a flowchart dropped them on top of each other. The
distinct origins only lived in createUnifiedDocument(), which the create flow
never calls.

Fix: seed the distinct frame origins (mind map 600,200 · flowchart 600,700) inside
createDiagramDocument itself for a unified type, so every unified doc gets
separated frames however it's built. createUnifiedDocument now just delegates.
Frames stay freely movable afterwards.

- schema.js: applyUnifiedFrameOrigins() called from createDiagramDocument when
  diagramType === unified; createUnifiedDocument delegates (no duplicate constants).
- unifiedDocument.test.js: assert the plain factory (the actual create-flow path)
  also seeds the distinct origins — the existing test only covered
  createUnifiedDocument, which is why the stacking slipped through.

Verified: vitest 101 pass; Playwright drive of the real app (create -> insert mind
map -> insert flowchart) shows the two frames spatially separated instead of
overlapping.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@greptile-apps

greptile-apps Bot commented Jul 20, 2026

Copy link
Copy Markdown

Confidence Score: 5/5

Safe to merge — targeted fix with a direct regression test covering the exact code path that was broken.

The change is small and focused: origin seeding moves one level up the call chain, createUnifiedDocument becomes a thin wrapper, and a new test guards the previously uncovered factory path. The existing 101-test suite still passes.

No files require special attention.

Reviews (1): Last reviewed commit: "Frappe Draw: unified frames no longer la..." | Re-trigger Greptile

Comment on lines +67 to 70
if (document.mindmap) document.mindmap.origin = { x: 600, y: 200 }
if (document.flowchart) document.flowchart.origin = { x: 600, y: 700 }
return document
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 The return document is unreferenced by the caller (mutation-in-place is what takes effect). Drop it to avoid implying the function is pure.

Suggested change
if (document.mindmap) document.mindmap.origin = { x: 600, y: 200 }
if (document.flowchart) document.flowchart.origin = { x: 600, y: 700 }
return document
}
if (document.mindmap) document.mindmap.origin = { x: 600, y: 200 }
if (document.flowchart) document.flowchart.origin = { x: 600, y: 700 }
}

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

@vibhavkatre
vibhavkatre merged commit f438e76 into main Jul 20, 2026
3 checks passed
@vibhavkatre
vibhavkatre deleted the fix/frame-insert-offset branch July 20, 2026 05:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants