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

Fix date picker being blank and jumpy when appearing

Christophe Bliard3594502240c7
diff --git a/frontend/src/app/shared/components/datepicker/modal-single-date-picker/modal-single-date-picker.component.ts b/frontend/src/app/shared/components/datepicker/modal-single-date-picker/modal-single-date-picker.component.ts
index 3f92c37bb71..6bb69b0dec8 100644
--- a/frontend/src/app/shared/components/datepicker/modal-single-date-picker/modal-single-date-picker.component.ts
+++ b/frontend/src/app/shared/components/datepicker/modal-single-date-picker/modal-single-date-picker.component.ts
@@ -52,7 +52,6 @@ import { debounce } from 'lodash';
import {
SpotDropModalTeleportationService,
} from 'core-app/spot/components/drop-modal/drop-modal-teleportation.service';
-import { delay } from 'rxjs';
// eslint-disable-next-line change-detection-strategy/on-push
@Component({
@@ -216,9 +215,6 @@ export class OpModalSingleDatePickerComponent implements ControlValueAccessor, O
private initializeDatepickerAfterOpen():void {
this.spotDropModalTeleportationService
.afterRenderOnce$(true)
- .pipe(
- delay(100),
- )
.subscribe(() => {
this.initializeDatepicker();
});
diff --git a/frontend/src/app/spot/components/drop-modal/drop-modal-portal.component.ts b/frontend/src/app/spot/components/drop-modal/drop-modal-portal.component.ts
index 85837d5aa07..756267b85fe 100644
--- a/frontend/src/app/spot/components/drop-modal/drop-modal-portal.component.ts
+++ b/frontend/src/app/spot/components/drop-modal/drop-modal-portal.component.ts
@@ -1,5 +1,4 @@
import {
- AfterViewChecked,
ChangeDetectionStrategy,
ChangeDetectorRef,
Component,
@@ -10,13 +9,12 @@ import {
import { SpotDropModalTeleportationService, TeleportInstance } from './drop-modal-teleportation.service';
import { UntilDestroyedMixin } from 'core-app/shared/helpers/angular/until-destroyed.mixin';
-
@Component({
selector: 'opce-spot-drop-modal-portal',
template: '<ng-container *ngTemplateOutlet="template"></ng-container>',
changeDetection: ChangeDetectionStrategy.OnPush,
})
-export class SpotDropModalPortalComponent extends UntilDestroyedMixin implements OnInit, AfterViewChecked {
+export class SpotDropModalPortalComponent extends UntilDestroyedMixin implements OnInit {
@HostBinding('class.spot-drop-modal-portal') className = true;
template:TeleportInstance|null = null;
@@ -39,10 +37,7 @@ export class SpotDropModalPortalComponent extends UntilDestroyedMixin implements
.subscribe((templ) => {
this.template = templ;
this.cdRef.detectChanges();
+ this.template$.hasRendered$.next(!!this.elementRef.nativeElement.children.length);
});
}
-
- ngAfterViewChecked():void {
- this.template$.hasRendered$.next(!!this.elementRef.nativeElement.children.length);
- }
}
diff --git a/frontend/src/app/spot/components/drop-modal/drop-modal.component.ts b/frontend/src/app/spot/components/drop-modal/drop-modal.component.ts
index 1f0169a7c68..2a5e4dc3153 100644
--- a/frontend/src/app/spot/components/drop-modal/drop-modal.component.ts
+++ b/frontend/src/app/spot/components/drop-modal/drop-modal.component.ts
@@ -109,15 +109,6 @@ export class SpotDropModalComponent implements OnDestroy {
open() {
this._opened = true;
this.updateAppHeight();
- this.cdRef.detectChanges();
-
- /*
- * If we don't activate the body after one tick, angular will complain because
- * it already rendered a `null` template, but then gets an update to that
- * template in the same tick.
- * To make it happy, we update afterwards
- */
- this.teleportationService.activate(this.body);
this.teleportationService
.hasRenderedFiltered$
@@ -126,6 +117,7 @@ export class SpotDropModalComponent implements OnDestroy {
take(1),
)
.subscribe(() => {
+ this.cdRef.detectChanges();
const referenceEl = this.elementRef.nativeElement as HTMLElement;
const floatingEl = this.anchor.nativeElement as HTMLElement;
this.cleanupFloatingUI = autoUpdate(
@@ -173,10 +165,16 @@ export class SpotDropModalComponent implements OnDestroy {
// Index 1 because the element at index 0 is the trigger button to open the modal
(findAllFocusableElementsWithin(document.querySelector('.spot-drop-modal-portal')!)[1])?.focus();
}
-
- this.cdRef.detectChanges();
});
});
+
+ /*
+ * If we don't activate the body after one tick, angular will complain because
+ * it already rendered a `null` template, but then gets an update to that
+ * template in the same tick.
+ * To make it happy, we update afterwards
+ */
+ this.teleportationService.activate(this.body);
}
close():void {