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

Remove input property binding from the datepicker ids.

Dombi Attila46e4bf1b3420
diff --git a/frontend/src/app/shared/components/datepicker/basic-range-date-picker/basic-range-date-picker.component.ts b/frontend/src/app/shared/components/datepicker/basic-range-date-picker/basic-range-date-picker.component.ts
index b57cea6b821..26736c813b0 100644
--- a/frontend/src/app/shared/components/datepicker/basic-range-date-picker/basic-range-date-picker.component.ts
+++ b/frontend/src/app/shared/components/datepicker/basic-range-date-picker/basic-range-date-picker.component.ts
@@ -102,7 +102,22 @@ export class OpBasicRangeDatePickerComponent implements OnInit, ControlValueAcce
return this._value;
}
- @Input() id = `flatpickr-input-${+(new Date())}`;
+ // Having an @Input property on the id will break the turbo morphing with idiomorph.
+ // The reason is, when the component does not have an id html attribute set the
+ // call element.id will still be answered by angular.
+ // This is problematic, because the new element coming from the response template
+ // does not have angular initialized on it yet, meaning it will respond with the html
+ // id attribute or an empty string.
+ // This also means that when idiomorph compares the new elements with the old ones,
+ // the same element will have a different id set and it will not be matched. The old element
+ // will have this angular @Input id property, the new one will have the html id attribute.
+ //
+ // The solution is to not have the id as an input property, this way the angular id won't
+ // interfere when calling the html id attribute of the component. The component would still
+ // get an id attribute assigned if provided when declaring the component, but it will not
+ // programatically overwrite the id accessor from angular.
+
+ id = `flatpickr-input-${+(new Date())}`;
@Input() name = '';
diff --git a/frontend/src/app/shared/components/datepicker/basic-single-date-picker/basic-single-date-picker.component.ts b/frontend/src/app/shared/components/datepicker/basic-single-date-picker/basic-single-date-picker.component.ts
index 34e7f9e1b54..17e7ff530a0 100644
--- a/frontend/src/app/shared/components/datepicker/basic-single-date-picker/basic-single-date-picker.component.ts
+++ b/frontend/src/app/shared/components/datepicker/basic-single-date-picker/basic-single-date-picker.component.ts
@@ -80,7 +80,21 @@ export class OpBasicSingleDatePickerComponent implements ControlValueAccessor, O
return this._value;
}
- @Input() id = `flatpickr-input-${+(new Date())}`;
+ // Having an @Input property on the id will break the turbo morphing with idiomorph.
+ // The reason is, when the component does not have an id html attribute set the
+ // call element.id will still be answered by angular.
+ // This is problematic, because the new element coming from the response template
+ // does not have angular initialized on it yet, meaning it will respond with the html
+ // id attribute or an empty string.
+ // This also means that when idiomorph compares the new elements with the old ones,
+ // the same element will have a different id set and it will not be matched. The old element
+ // will have this angular @Input id property, the new one will have the html id attribute.
+ //
+ // The solution is to not have the id as an input property, this way the angular id won't
+ // interfere when calling the html id attribute of the component. The component would still
+ // get an id attribute assigned if provided when declaring the component, but it will not
+ // programatically overwrite the id accessor from angular.
+ id = `flatpickr-input-${+(new Date())}`;
@Input() name = '';