Skip to content

Commit d88853d

Browse files
committed
Fix crash on copy
1 parent e6d29ed commit d88853d

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

src/components/EditorHeader/ControlPanel.jsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -709,12 +709,15 @@ export default function ControlPanel({
709709
return;
710710
}
711711
const v = new Validator();
712+
console.log(obj);
712713
if (v.validate(obj, tableSchema).valid) {
713714
addTable({
714-
...obj,
715-
x: obj.x + 20,
716-
y: obj.y + 20,
717-
id: nanoid(),
715+
table: {
716+
...obj,
717+
x: obj.x + 20,
718+
y: obj.y + 20,
719+
id: nanoid(),
720+
},
718721
});
719722
} else if (v.validate(obj, areaSchema).valid) {
720723
addArea({

src/context/DiagramContext.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export default function DiagramContextProvider({ children }) {
4545
if (data) {
4646
setTables((prev) => {
4747
const temp = prev.slice();
48-
temp.splice(data.index, 0, data.table);
48+
temp.splice(data.index || tables.length, 0, data.table);
4949
return temp;
5050
});
5151
} else {

0 commit comments

Comments
 (0)