There was an error while loading. Please reload this page.
1 parent da0f084 commit da85174Copy full SHA for da85174
src/context/DiagramContext.jsx
@@ -18,11 +18,24 @@ export default function DiagramContextProvider({ children }) {
18
19
const addTable = (data, addToHistory = true) => {
20
const id = nanoid();
21
+
22
+ // Calculate position for new table with offset to avoid overlap
23
+ let newPosition = { x: transform.pan.x, y: transform.pan.y };
24
25
+ if (!data && tables.length > 0) {
26
+ const lastTable = tables[tables.length - 1];
27
+ // Offset by 50px diagonally from the last table
28
+ newPosition = {
29
+ x: lastTable.x + 50,
30
+ y: lastTable.y + 50,
31
+ };
32
+ }
33
34
const newTable = {
35
id,
36
name: `table_${id}`,
- x: transform.pan.x,
- y: transform.pan.y,
37
+ x: newPosition.x,
38
+ y: newPosition.y,
39
locked: false,
40
fields: [
41
{
0 commit comments