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

Only position on the first initialization of datepicker

Oliver Güntherb8ccddacd9ed
diff --git a/frontend/src/app/shared/components/datepicker/multi-date-modal/multi-date.modal.ts b/frontend/src/app/shared/components/datepicker/multi-date-modal/multi-date.modal.ts
index 4c4bbbb78a8..bd3884a10b1 100644
--- a/frontend/src/app/shared/components/datepicker/multi-date-modal/multi-date.modal.ts
+++ b/frontend/src/app/shared/components/datepicker/multi-date-modal/multi-date.modal.ts
@@ -168,6 +168,10 @@ export class MultiDateModalComponent extends OpModalComponent implements AfterVi
// Manual changes to the datepicker, with information which field was active
datepickerChanged$ = new Subject<ActiveDateChange>();
+ // We want to position the modal as soon as the datepicker gets initialized
+ // But if we destroy and recreate the datepicker (e.g., when toggling switches), keep current position
+ modalPositioned = false;
+
// Date updates from the datepicker or a manual change
dateUpdates$ = merge(
this.startDateDebounced$,
@@ -465,7 +469,12 @@ export class MultiDateModalComponent extends OpModalComponent implements AfterVi
inline: true,
onReady: (_date, _datestr, instance) => {
instance.calendarContainer.classList.add('op-datepicker-modal--flatpickr-instance');
- this.reposition(jQuery(this.modalContainer.nativeElement), jQuery(`.${activeFieldContainerClassName}`));
+
+ if (!this.modalPositioned) {
+ this.reposition(jQuery(this.modalContainer.nativeElement), jQuery(`.${activeFieldContainerClassName}`));
+ this.modalPositioned = true;
+ }
+
this.ensureHoveredSelection(instance.calendarContainer);
},
onChange: (dates:Date[], _datestr, instance) => {