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

Annotate intent behind setting the change event listeners in Stimulus controllers

Aaron Contreras30a891ca5bff
diff --git a/frontend/src/stimulus/controllers/dynamic/filter/filters-form.controller.ts b/frontend/src/stimulus/controllers/dynamic/filter/filters-form.controller.ts
index 23c7ae1e68d..bacd2cc7cbb 100644
--- a/frontend/src/stimulus/controllers/dynamic/filter/filters-form.controller.ts
+++ b/frontend/src/stimulus/controllers/dynamic/filter/filters-form.controller.ts
@@ -79,6 +79,8 @@ export default class FiltersFormController extends Controller {
const urlParams = new URLSearchParams(window.location.search);
this.displayFiltersValue = urlParams.has('filters');
+ // Auto-register change event listeners for all fields
+ // to keep DOM cleaner.
this.simpleValueTargets.forEach((simpleValue) => {
simpleValue.addEventListener('change', this.sendForm.bind(this));
});
@@ -105,6 +107,8 @@ export default class FiltersFormController extends Controller {
}
disconnect() {
+ // Auto-deregister change event listeners for all fields
+ // to keep DOM cleaner.
this.simpleValueTargets.forEach((simpleValue) => {
simpleValue.removeEventListener('change', this.sendForm.bind(this));
});