Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

debounce requests to recalculate budget after updating count

Ivan Kuchin7778e695a177
diff --git a/frontend/src/stimulus/controllers/dynamic/costs/budget-subform.controller.ts b/frontend/src/stimulus/controllers/dynamic/costs/budget-subform.controller.ts
index 9e722d6d440..36b21a4fcfa 100644
--- a/frontend/src/stimulus/controllers/dynamic/costs/budget-subform.controller.ts
+++ b/frontend/src/stimulus/controllers/dynamic/costs/budget-subform.controller.ts
@@ -55,11 +55,19 @@ export default class BudgetSubformController extends Controller {
this.submitButtons = this.form.querySelectorAll("button[type='submit']");
}
+ private debounceTimers:{ [id:string]:ReturnType<typeof setTimeout> } = {};
+
valueChanged(evt:Event) {
const row = this.eventRow(evt.target);
if (row) {
- void this.refreshRow(row.getAttribute('id') as string);
+ const id:string = row.getAttribute('id') as string;
+
+ clearTimeout(this.debounceTimers[id]);
+
+ this.debounceTimers[id] = setTimeout(() => {
+ void this.refreshRow(id);
+ }, 100);
}
}