Skip to content

Commit afe4896

Browse files
1ilitewqazxc
authored andcommitted
Retain table id after redo (drawdb-io#659)
1 parent 7c5a280 commit afe4896

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/components/EditorHeader/ControlPanel.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ export default function ControlPanel({
341341

342342
if (a.action === Action.ADD) {
343343
if (a.element === ObjectType.TABLE) {
344-
addTable(null, false);
344+
addTable(null, false, a.id);
345345
} else if (a.element === ObjectType.AREA) {
346346
addArea(null, false);
347347
} else if (a.element === ObjectType.NOTE) {

src/context/DiagramContext.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ export default function DiagramContextProvider({ children }) {
1616
const { setUndoStack, setRedoStack } = useUndoRedo();
1717
const { selectedElement, setSelectedElement } = useSelect();
1818

19-
const addTable = (data, addToHistory = true) => {
20-
const id = nanoid();
19+
const addTable = (data, addToHistory = true, idToUse = null) => {
20+
const id = idToUse || nanoid();
2121
if (data) {
2222
setTables((prev) => {
2323
const temp = prev.slice();

0 commit comments

Comments
 (0)