mirror of
https://github.com/drawdb-io/drawdb.git
synced 2025-11-28 01:06:38 +08:00
Fix crash on copy and duplicate table (#679)
* Fix crash on copy * Fix duplicatte
This commit is contained in:
@@ -647,10 +647,12 @@ export default function ControlPanel({
|
||||
case ObjectType.TABLE: {
|
||||
const copiedTable = tables.find((t) => t.id === selectedElement.id);
|
||||
addTable({
|
||||
...copiedTable,
|
||||
x: copiedTable.x + 20,
|
||||
y: copiedTable.y + 20,
|
||||
id: nanoid(),
|
||||
table: {
|
||||
...copiedTable,
|
||||
x: copiedTable.x + 20,
|
||||
y: copiedTable.y + 20,
|
||||
id: nanoid(),
|
||||
},
|
||||
});
|
||||
break;
|
||||
}
|
||||
@@ -709,12 +711,15 @@ export default function ControlPanel({
|
||||
return;
|
||||
}
|
||||
const v = new Validator();
|
||||
console.log(obj);
|
||||
if (v.validate(obj, tableSchema).valid) {
|
||||
addTable({
|
||||
...obj,
|
||||
x: obj.x + 20,
|
||||
y: obj.y + 20,
|
||||
id: nanoid(),
|
||||
table: {
|
||||
...obj,
|
||||
x: obj.x + 20,
|
||||
y: obj.y + 20,
|
||||
id: nanoid(),
|
||||
},
|
||||
});
|
||||
} else if (v.validate(obj, areaSchema).valid) {
|
||||
addArea({
|
||||
|
||||
@@ -45,7 +45,7 @@ export default function DiagramContextProvider({ children }) {
|
||||
if (data) {
|
||||
setTables((prev) => {
|
||||
const temp = prev.slice();
|
||||
temp.splice(data.index, 0, data.table);
|
||||
temp.splice(data.index || tables.length, 0, data.table);
|
||||
return temp;
|
||||
});
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user