Skip to content

Commit 0d07166

Browse files
myabcbsatarnejad
andcommitted
Remove workaround for Idiomorph bug in date-picker
This should now be fixed. See bigskysoftware/idiomorph#131 Co-Authored-By: Behrokh Satarnejad <62008897+bsatarnejad@users.noreply.github.com>
1 parent 2cf6d1a commit 0d07166

2 files changed

Lines changed: 2 additions & 20 deletions

File tree

frontend/src/app/shared/components/datepicker/basic-single-date-picker/basic-single-date-picker.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
[ngModel]="value"
1010
[attr.data-value]="value"
1111
[attr.data-action]="dataAction"
12-
[id]="inputId"
12+
[id]="id"
1313
[name]="name"
1414
[attr.name]="name"
1515
[required]="required"

frontend/src/app/shared/components/datepicker/basic-single-date-picker/basic-single-date-picker.component.ts

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -81,25 +81,7 @@ export class OpBasicSingleDatePickerComponent implements ControlValueAccessor, O
8181
return this._value;
8282
}
8383

84-
// Having an `@Input() id;` property breaks the turbo morphing with idiomorph.
85-
// The reason is, the `id` set by angular will override the `id` set as html attribute on
86-
// the component.
87-
// This is problematic, because new elements from the response template
88-
// will not have angular initialized on them, and calling `element.id` will return the html
89-
// id attribute, while calling `element.id` on existing elements will return the angular
90-
// defined `id` property.
91-
// It also means, when idiomorph compares the new elements with the old ones,
92-
// the same element will have a different id set, and it will not be matched. The old element
93-
// will have the angular `@Input id` property, while new one will have the html id attribute.
94-
//
95-
// The solution is to rename the `id` to `inputId`. The component would still get an id
96-
// attribute assigned if provided when declaring the component, but angular will not
97-
// programatically overwrite the `id` getter.
98-
//
99-
// This comment can be removed once the https://github.com/bigskysoftware/idiomorph/pull/131
100-
// is accepted.
101-
102-
@Input() inputId = `flatpickr-input-${+(new Date())}`;
84+
@Input() id = `flatpickr-input-${+(new Date())}`;
10385

10486
@Input() name = '';
10587

0 commit comments

Comments
 (0)