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

concentrate top-layer handling in single method

ulferts40d54c4236d4
diff --git a/frontend/src/app/shared/components/datepicker/basic-range-date-picker/basic-range-date-picker.component.html b/frontend/src/app/shared/components/datepicker/basic-range-date-picker/basic-range-date-picker.component.html
index e083c264ab1..05fe101b3ce 100644
--- a/frontend/src/app/shared/components/datepicker/basic-range-date-picker/basic-range-date-picker.component.html
+++ b/frontend/src/app/shared/components/datepicker/basic-range-date-picker/basic-range-date-picker.component.html
@@ -16,6 +16,7 @@
[ngModel]="stringValue"
(ngModelChange)="changeValueFromInputDebounced($event)"
(focus)="showDatePicker()"
+ (click)="sentCalendarToTopLayer()"
/>
<ng-container *ngIf="mobile">
<input
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 56e261aa7fb..897f37c5606 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
@@ -170,7 +170,10 @@ export class OpBasicRangeDatePickerComponent implements OnInit, ControlValueAcce
}
showDatePicker():void {
- this.datePickerInstance?.show();
+ if (!this.datePickerInstance?.isOpen) {
+ this.datePickerInstance?.show();
+ this.sentCalendarToTopLayer();
+ }
}
private initializeDatePicker() {
@@ -184,7 +187,6 @@ export class OpBasicRangeDatePickerComponent implements OnInit, ControlValueAcce
showMonths: 2,
onReady: (_date:Date[], _datestr:string, instance:flatpickr.Instance) => {
instance.calendarContainer.classList.add('op-datepicker-modal--flatpickr-instance');
- instance.calendarContainer.setAttribute('popover', '');
},
onChange: (dates:Date[], dateStr:string) => {
if (dates.length === 2) {
@@ -196,12 +198,6 @@ export class OpBasicRangeDatePickerComponent implements OnInit, ControlValueAcce
this.cdRef.detectChanges();
},
- onOpen: (_date:Date[], _datestr:string, instance:flatpickr.Instance) => {
- setTimeout(() => {
- instance.calendarContainer.showPopover();
- instance.calendarContainer.style.marginTop = '0';
- });
- },
onDayCreate: async (dObj:Date[], dStr:string, fp:flatpickr.Instance, dayElem:DayElement) => {
onDayCreate(
dayElem,
@@ -241,4 +237,23 @@ export class OpBasicRangeDatePickerComponent implements OnInit, ControlValueAcce
private resolveDateArrayToString(dates:string[]):string {
return dates.join(` ${rangeSeparator} `);
}
+
+ // In case the date picker is opened in a dialog, it needs to be in the top layer
+ // since the dialog is also there. This method is called in two cases:
+ // 1. When the date picker is opened
+ // 2. When the date picker is already opened and the user clicks on the input
+ // The later is necessary as otherwise the date picker would be removed from the top layer
+ // when the user clicks on the input. That is because the input is not part of the date picker
+ // so clicking on it would be considered a click on the backdrop which removes an item from
+ // the top layer again.
+ public sentCalendarToTopLayer() {
+ if (!this.datePickerInstance.isOpen || !this.inDialog) {
+ return;
+ }
+
+ const calendarContainer = this.datePickerInstance.datepickerInstance.calendarContainer;
+ calendarContainer.setAttribute('popover', '');
+ calendarContainer.showPopover();
+ calendarContainer.style.marginTop = '0';
+ }
}