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

Update datepicker inputId comment to describe the bug better.

Dombi Attilabbdddd77a5f2
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 e9e98339a65..8d8cc4271b6 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,20 +102,23 @@ export class OpBasicRangeDatePickerComponent implements OnInit, ControlValueAcce
return this._value;
}
- // 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.
+ // Having an `@Input() id;` property breaks the turbo morphing with idiomorph.
+ // The reason is, the `id` set by angular will override the `id` set as html attribute on
+ // the component.
+ // This is problematic, because new elements from the response template
+ // will not have angular initialized on them, and calling `element.id` will return the html
+ // id attribute, while calling `element.id` on existing elements will return the angular
+ // defined `id` property.
+ // It also means, 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 the angular `@Input id` property, while 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.
+ // The solution is to rename the `id` to `inputId`. The component would still get an id
+ // attribute assigned if provided when declaring the component, but angular will not
+ // programatically overwrite the `id` getter.
+ //
+ // This comment can be removed once the https://github.com/bigskysoftware/idiomorph/pull/131
+ // is accepted.
@Input() inputId = `flatpickr-input-${+(new Date())}`;
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 e6538c17b03..828e48cf706 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,20 +80,24 @@ export class OpBasicSingleDatePickerComponent implements ControlValueAccessor, O
return this._value;
}
- // 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.
+ // Having an `@Input() id;` property breaks the turbo morphing with idiomorph.
+ // The reason is, the `id` set by angular will override the `id` set as html attribute on
+ // the component.
+ // This is problematic, because new elements from the response template
+ // will not have angular initialized on them, and calling `element.id` will return the html
+ // id attribute, while calling `element.id` on existing elements will return the angular
+ // defined `id` property.
+ // It also means, 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 the angular `@Input id` property, while 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.
+ // The solution is to rename the `id` to `inputId`. The component would still get an id
+ // attribute assigned if provided when declaring the component, but angular will not
+ // programatically overwrite the `id` getter.
+ //
+ // This comment can be removed once the https://github.com/bigskysoftware/idiomorph/pull/131
+ // is accepted.
+
@Input() inputId = `flatpickr-input-${+(new Date())}`;
@Input() name = '';