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

have an explicit html id to enable idiomorph to match new and old dom element

ulferts97e684795d5e
diff --git a/app/forms/projects/life_cycles/form.rb b/app/forms/projects/life_cycles/form.rb
index 06a7ec6212d..b678bf93468 100644
--- a/app/forms/projects/life_cycles/form.rb
+++ b/app/forms/projects/life_cycles/form.rb
@@ -44,7 +44,7 @@ module Projects::LifeCycles
end
end
- def qa_field_name
+ def field_id
"life-cycle-step-#{model.id}"
end
@@ -54,10 +54,14 @@ module Projects::LifeCycles
leading_visual: { icon: :calendar },
datepicker_options: {
inDialog: ProjectLifeCycles::Sections::EditDialogComponent::DIALOG_ID,
- data: { action: "change->overview--project-life-cycles-form#previewForm" }
+ data: { action: "change->overview--project-life-cycles-form#previewForm" },
+ # An id is required on the angular dom element to have the turbo morphing identify
+ # the custom dom uniquely when updating the form. Otherwise, there will be two fields
+ # after the first update.
+ component_id: field_id
},
wrapper_data_attributes: {
- "qa-field-name": qa_field_name
+ "qa-field-name": field_id
}
}
end
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..fb99576cd5b 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
@@ -137,11 +137,13 @@ export class OpBasicRangeDatePickerComponent implements OnInit, ControlValueAcce
readonly cdRef:ChangeDetectorRef,
readonly elementRef:ElementRef,
readonly deviceService:DeviceService,
- ) {
- populateInputsFromDataset(this);
- }
+ ) {}
ngOnInit() {
+ // The populateInputsFromDataset function is called here and not in the constructor as this way,
+ // the inputs are filled in the last possible moment. This prevents the id attribute on the angular element from being
+ // used as the input instead of what is set in the dataset.
+ populateInputsFromDataset(this);
this.mobile = this.deviceService.isMobile;
}
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..e06e6b4fde9 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
@@ -116,11 +116,13 @@ export class OpBasicSingleDatePickerComponent implements ControlValueAccessor, O
readonly cdRef:ChangeDetectorRef,
readonly elementRef:ElementRef,
readonly deviceService:DeviceService,
- ) {
- populateInputsFromDataset(this);
- }
+ ) {}
ngOnInit() {
+ // The populateInputsFromDataset function is called here and not in the constructor as this way,
+ // the inputs are filled in the last possible moment. This prevents the id attribute on the angular element from being
+ // used as the input instead of what is set in the dataset.
+ populateInputsFromDataset(this);
this.mobile = this.deviceService.isMobile;
}
diff --git a/lib/primer/open_project/forms/date_picker.html.erb b/lib/primer/open_project/forms/date_picker.html.erb
index 147f06d4284..8ac47afe44f 100644
--- a/lib/primer/open_project/forms/date_picker.html.erb
+++ b/lib/primer/open_project/forms/date_picker.html.erb
@@ -40,6 +40,8 @@ See COPYRIGHT and LICENSE files for more details.
<% end %>
<%= render Primer::ConditionalWrapper.new(condition: @input.auto_check_src, tag: "auto-check", csrf: auto_check_authenticity_token, src: @input.auto_check_src) do %>
<%= angular_component_tag @datepicker_options.fetch(:component),
+ id: @datepicker_options.fetch(:component_id) {},
+ "data-turbo-permanent": true,
inputs: @datepicker_options.merge(
id: @datepicker_options.fetch(:id) { builder.field_id(@input.name) },
name: @datepicker_options.fetch(:name) { builder.field_name(@input.name) },