From 1ab88dedb35c9dec7dd1293734b4de516af67ac6 Mon Sep 17 00:00:00 2001 From: charles-ramos Date: Fri, 27 Nov 2026 16:06:32 -0300 Subject: [PATCH] Prevent duplicate row when double clicking Add Ignore repeated calls to saveNewRow while a save is in flight, so the same object is no longer prepended to the table twice. Co-Authored-By: Claude Opus 5.5 --- src/dashboard/Data/Browser/Browser.react.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/dashboard/Data/Browser/Browser.react.js b/src/dashboard/Data/Browser/Browser.react.js index 7547c736ea..8a2bf860d2 100644 --- a/src/dashboard/Data/Browser/Browser.react.js +++ b/src/dashboard/Data/Browser/Browser.react.js @@ -1102,7 +1102,9 @@ class Browser extends DashboardView { saveNewRow() { const { useMasterKey } = this.state; const obj = this.state.newObject; - if (!obj) { + // Ignore repeated clicks (e.g. double click on "Add") while a save is in flight, + // otherwise the same object gets saved and prepended to the table twice. + if (!obj || this.savingNewRow) { return; } @@ -1145,6 +1147,7 @@ class Browser extends DashboardView { markRequiredFieldRow: 0, }); } + this.savingNewRow = true; obj.save(null, { useMasterKey }).then( objectSaved => { const msg = objectSaved.className + ' with id \'' + objectSaved.id + '\' created'; @@ -1160,7 +1163,7 @@ class Browser extends DashboardView { const parentRelation = parent.relation(relation.key); parentRelation.add(obj); const targetClassName = relation.targetClassName; - parent.save(null, { useMasterKey }).then( + return parent.save(null, { useMasterKey }).then( () => { this.setState({ newObject: null, @@ -1199,7 +1202,9 @@ class Browser extends DashboardView { } this.showNote(msg, true); } - ); + ).finally(() => { + this.savingNewRow = false; + }); } saveEditCloneRow(rowIndex) {