Skip to content

Commit fe3d495

Browse files
committed
[IMP] add timed delay on creation refresh
1 parent d6c8b1d commit fe3d495

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

spp_custom_fields_ui/static/src/js/custom_fields_ui_reload.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,25 @@ patch(FormController.prototype, {
1616
return super.saveButtonClicked(params);
1717
}
1818

19+
// Check if this is a new record (before save)
20+
const isNewRecord = !this.model.root.resId;
21+
1922
// Try to save
2023
try {
2124
const result = await super.saveButtonClicked(params);
2225

2326
// Only reload if save was successful
24-
// If result is defined and not false, save was successful
2527
if (result !== false) {
26-
// Reload the page to refresh the model registry
27-
// The URL will contain the record ID (for both new and existing records)
28-
window.location.reload();
28+
if (isNewRecord) {
29+
// For new records, wait a bit for URL to update, then reload
30+
// This ensures the URL contains the new record ID
31+
setTimeout(() => {
32+
window.location.reload();
33+
}, 100);
34+
} else {
35+
// For existing records, reload immediately
36+
window.location.reload();
37+
}
2938
}
3039

3140
return result;

0 commit comments

Comments
 (0)