Skip to content

Free, simple, and intuitive online database diagram editor and SQL generator.

dynamically remove fields to tables

1ilitcc1a73d6dd19
diff --git a/src/components/rect.jsx b/src/components/rect.jsx
index d436376c..398e8391 100644
--- a/src/components/rect.jsx
+++ b/src/components/rect.jsx
@@ -36,7 +36,7 @@ const Rect = (props) => {
name: "Students",
};
- const height = fields.length * 36 + (fields.length - 1) * 2 + 40 + 2;
+ const height = fields.length * 36 + 40 + 2;
return (
<g>
@@ -114,7 +114,14 @@ const Rect = (props) => {
<button className="btn bg-sky-800 text-white text-xs py-1 px-2 me-2 opacity-80">
<IconEdit />
</button>
- <button className="btn bg-red-800 text-white text-xs py-1 px-2 opacity-80">
+ <button
+ className="btn bg-red-800 text-white text-xs py-1 px-2 opacity-80"
+ onClick={(e) => {
+ const updatedFields = [...fields];
+ updatedFields.splice(i, 1);
+ setFields(updatedFields);
+ }}
+ >
<IconMinus />
</button>
</div>