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

Change the modalOverlay height calculation to make sure that the Datepicker is correctly shown when opened on iOS and the keyboard opens

Henriette Darge25238cd612b3
diff --git a/frontend/src/app/shared/components/modal/modal.component.ts b/frontend/src/app/shared/components/modal/modal.component.ts
index 78f4ca9749c..62d5ab175fd 100644
--- a/frontend/src/app/shared/components/modal/modal.component.ts
+++ b/frontend/src/app/shared/components/modal/modal.component.ts
@@ -94,7 +94,8 @@ export abstract class OpModalComponent extends UntilDestroyedMixin implements On
this.updateAppHeight();
this.cdRef.detectChanges();
- window.addEventListener('resize', this.onResize);
+ // It is important to check for visualViewport changes as that includes also keyboard opening (especially on iOS)
+ window.visualViewport?.addEventListener('resize', this.onResize);
window.addEventListener('orientationchange', this.onResize);
}
diff --git a/frontend/src/app/spot/styles/sass/components/modal-overlay.sass b/frontend/src/app/spot/styles/sass/components/modal-overlay.sass
index d1a0bdc11f2..0995ef9c968 100644
--- a/frontend/src/app/spot/styles/sass/components/modal-overlay.sass
+++ b/frontend/src/app/spot/styles/sass/components/modal-overlay.sass
@@ -10,6 +10,13 @@
align-items: center
display: none
+ .-browser-safari &
+ // Again, iOS and Safari are being special. When the keyboard opens, that pushes the whole viewport to the top.
+ // Thus, when using `top: 0` half of the modal is pushed out of the screen.
+ // Instead, we only set `bottom: 0` and set the height to the app height which is set programmatically on every screen resize
+ height: var(--app-height)
+ top: unset
+
&_active
display: flex
flex-direction: column-reverse
diff --git a/frontend/src/stimulus/controllers/dynamic/work-packages/date-picker/preview.controller.ts b/frontend/src/stimulus/controllers/dynamic/work-packages/date-picker/preview.controller.ts
index 28467267a80..59e9ba910c9 100644
--- a/frontend/src/stimulus/controllers/dynamic/work-packages/date-picker/preview.controller.ts
+++ b/frontend/src/stimulus/controllers/dynamic/work-packages/date-picker/preview.controller.ts
@@ -373,6 +373,10 @@ export default class PreviewController extends DialogPreviewController {
const fieldToHighlight = e.target as HTMLInputElement;
if (fieldToHighlight) {
this.highlightField(fieldToHighlight);
+ window.setTimeout(() => {
+ // For mobile, we have to make sure that the active field is scrolled into view after the keyboard is opened
+ fieldToHighlight.scrollIntoView(true);
+ }, 200);
// Datepicker can need an update when the focused field changes. This
// allows to switch between single and range mode in certain edge cases.
this.readCurrentValues();