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

scroll into view when it is a mobile device

bsatarnejad57f28ca32298
diff --git a/frontend/src/app/features/work-packages/components/wp-activity/user/user-activity.component.ts b/frontend/src/app/features/work-packages/components/wp-activity/user/user-activity.component.ts
index 0211e271942..0605a3730c1 100644
--- a/frontend/src/app/features/work-packages/components/wp-activity/user/user-activity.component.ts
+++ b/frontend/src/app/features/work-packages/components/wp-activity/user/user-activity.component.ts
@@ -48,6 +48,7 @@ import { WorkPackageResource } from 'core-app/features/hal/resources/work-packag
import { UserResource } from 'core-app/features/hal/resources/user-resource';
import { HalResource } from 'core-app/features/hal/resources/hal-resource';
import idFromLink from 'core-app/features/hal/helpers/id-from-link';
+import { DeviceService } from 'core-app/core/browser/device.service';
@Component({
selector: 'user-activity',
@@ -110,6 +111,7 @@ export class UserActivityComponent extends WorkPackageCommentFieldHandler implem
readonly cdRef:ChangeDetectorRef,
readonly I18n:I18nService,
readonly ngZone:NgZone,
+ readonly deviceService:DeviceService,
protected appRef:ApplicationRef) {
super(elementRef, injector);
}
@@ -148,11 +150,15 @@ export class UserActivityComponent extends WorkPackageCommentFieldHandler implem
});
if (window.location.hash === `#activity-${this.activityNo}`) {
- const activityElement = document.querySelectorAll(`[data-qa-activity-number='${this.activityNo}']`)[0] as HTMLElement;
- const scrollContainer = document.querySelectorAll("[data-notification-selector='notification-scroll-container']")[0];
- const scrollOffset = activityElement.offsetTop - (scrollContainer as HTMLElement).offsetTop - this.additionalScrollMargin;
this.ngZone.runOutsideAngular(() => {
setTimeout(() => {
+ if (this.deviceService.isMobile) {
+ this.elementRef.nativeElement.scrollIntoView(true);
+ return;
+ }
+ const activityElement = document.querySelectorAll(`[data-qa-activity-number='${this.activityNo}']`)[0] as HTMLElement;
+ const scrollContainer = document.querySelectorAll("[data-notification-selector='notification-scroll-container']")[0];
+ const scrollOffset = activityElement.offsetTop - (scrollContainer as HTMLElement).offsetTop - this.additionalScrollMargin;
scrollContainer.scrollTop = scrollOffset;
});
});
diff --git a/frontend/src/app/features/work-packages/components/wp-single-view-tabs/activity-panel/activity-base.controller.ts b/frontend/src/app/features/work-packages/components/wp-single-view-tabs/activity-panel/activity-base.controller.ts
index 02a0841effb..a7b62459f3c 100644
--- a/frontend/src/app/features/work-packages/components/wp-single-view-tabs/activity-panel/activity-base.controller.ts
+++ b/frontend/src/app/features/work-packages/components/wp-single-view-tabs/activity-panel/activity-base.controller.ts
@@ -44,6 +44,7 @@ import { UntilDestroyedMixin } from 'core-app/shared/helpers/angular/until-destr
import { ApiV3Service } from 'core-app/core/apiv3/api-v3.service';
import { WpSingleViewService } from 'core-app/features/work-packages/routing/wp-view-base/state/wp-single-view.service';
import { BrowserDetector } from 'core-app/core/browser/browser-detector.service';
+import { DeviceService } from 'core-app/core/browser/device.service';
@Directive()
export class ActivityPanelBaseController extends UntilDestroyedMixin implements OnInit {
@@ -85,6 +86,7 @@ export class ActivityPanelBaseController extends UntilDestroyedMixin implements
readonly storeService:WpSingleViewService,
readonly browserDetector:BrowserDetector,
private wpSingleViewService:WpSingleViewService,
+ readonly deviceService:DeviceService,
) {
super();
@@ -203,7 +205,7 @@ export class ActivityPanelBaseController extends UntilDestroyedMixin implements
scrollContainer.scrollTop = scrollOffset;
// Make sure the scrollContainer is visible on mobile
- if (this.comingFromNotifications) {
+ if (this.comingFromNotifications && this.deviceService.isMobile) {
scrollContainer.scrollIntoView(true);
}
}