Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions src/dashboard/Data/Browser/Browser.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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';
Expand All @@ -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,
Expand Down Expand Up @@ -1199,7 +1202,9 @@ class Browser extends DashboardView {
}
this.showNote(msg, true);
}
);
).finally(() => {
this.savingNewRow = false;
});
}

saveEditCloneRow(rowIndex) {
Expand Down
Loading