fix: offset new elements to prevent overlap at same position by 20syldev · Pull Request #999 · drawdb-io/drawdb · GitHub
Skip to content

fix: offset new elements to prevent overlap at same position#999

Open
20syldev wants to merge 1 commit intodrawdb-io:mainfrom
20syldev:fix/new-element-overlap
Open

fix: offset new elements to prevent overlap at same position#999
20syldev wants to merge 1 commit intodrawdb-io:mainfrom
20syldev:fix/new-element-overlap

Conversation

@20syldev
Copy link
Copy Markdown
Contributor

Summary

  • Tables, notes, and areas were all placed at (transform.pan.x, transform.pan.y) when created, causing every new element to stack on top of the previous ones
  • Added a position check in addTable (DiagramContext), addNote (NotesContext), and addArea (AreasContext): if an existing element of the same type already occupies the target position, increment both x and y by 20px until a free spot is found
  • This mirrors the existing +20px offset pattern already used by the duplicate function in ControlPanel.jsx

Test plan

  • Add multiple tables without moving the canvas — each should appear offset from the previous one
  • Same test for notes and areas
  • Undo/redo behavior should still work correctly
  • Elements created from history restore (with data argument) are unaffected

Fixes #736

Tables, notes, and areas were all placed at the same coordinates
(transform.pan.x/y), causing every new element to stack on top
of the previous ones. Now each context incrementally offsets by
20px until a free position is found.

Fixes drawdb-io#736
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 20, 2026

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.

[BUG]New Elements (Tables, Notes, Areas) Overlap at Same Position

1 participant