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

[38693] Scroll to oldest unread activity in the activity tab (#9606)

Behrokh Satarnejadb216d43ae922
diff --git a/frontend/src/app/features/work-packages/components/wp-activity/user/user-activity.component.sass b/frontend/src/app/features/work-packages/components/wp-activity/user/user-activity.component.sass
index c95b2506db0..af5d36d7257 100644
--- a/frontend/src/app/features/work-packages/components/wp-activity/user/user-activity.component.sass
+++ b/frontend/src/app/features/work-packages/components/wp-activity/user/user-activity.component.sass
@@ -16,3 +16,7 @@
&--avatar
flex-shrink: 0
+
+ &--unread-notification-bubble
+ &_scrolled
+ scroll-margin-top: 200px
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 d34daf2c890..4bf2af7b760 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
@@ -90,9 +90,10 @@ export class ActivityPanelBaseController extends UntilDestroyedMixin implements
.pipe(this.untilDestroyed())
.subscribe((wp) => {
this.workPackage = wp;
- this.wpActivity.require(this.workPackage).then((activities:any) => {
+ void this.wpActivity.require(this.workPackage).then((activities:HalResource[]) => {
this.updateActivities(activities);
this.cdRef.detectChanges();
+ this.scrollToUnreadNotification();
});
});
@@ -142,6 +143,25 @@ export class ActivityPanelBaseController extends UntilDestroyedMixin implements
);
}
+ protected scrollToUnreadNotification():void {
+ // scroll to the unread notification only if there is no deep link
+ if (window.location.href.indexOf('activity#') > -1) {
+ return;
+ }
+ const unreadNotifications = document.querySelectorAll('.comments-number--bubble');
+ const unreadNotificationsLength = unreadNotifications?.length;
+ if (!unreadNotificationsLength) {
+ return;
+ }
+ if (this.reverse) {
+ unreadNotifications[unreadNotificationsLength - 1].classList.add('op-user-activity--unread-notification-bubble_scrolled');
+ unreadNotifications[unreadNotificationsLength - 1].scrollIntoView();
+ } else {
+ unreadNotifications[0].classList.add('op-user-activity--unread-notification-bubble_scrolled');
+ unreadNotifications[0].scrollIntoView();
+ }
+ }
+
public toggleComments():void {
this.onlyComments = !this.onlyComments;
this.updateActivities(this.unfilteredActivities);
diff --git a/frontend/src/app/features/work-packages/components/wp-tabs/components/wp-tabs/wp-tabs.component.html b/frontend/src/app/features/work-packages/components/wp-tabs/components/wp-tabs/wp-tabs.component.html
index a98e2041765..b2195687cfd 100644
--- a/frontend/src/app/features/work-packages/components/wp-tabs/components/wp-tabs/wp-tabs.component.html
+++ b/frontend/src/app/features/work-packages/components/wp-tabs/components/wp-tabs/wp-tabs.component.html
@@ -1,6 +1,6 @@
<op-scrollable-tabs
[tabs]="tabs"
- class="op-work-package-tabs"
+ class="op-work-package-tabs op-work-package-tabs_sticky"
>
<ng-container slot="actions" *ngIf="view === 'split'">
<li class="tab-icon">
diff --git a/frontend/src/app/features/work-packages/components/wp-tabs/components/wp-tabs/wp-tabs.component.sass b/frontend/src/app/features/work-packages/components/wp-tabs/components/wp-tabs/wp-tabs.component.sass
index e69de29bb2d..059677001f7 100644
--- a/frontend/src/app/features/work-packages/components/wp-tabs/components/wp-tabs/wp-tabs.component.sass
+++ b/frontend/src/app/features/work-packages/components/wp-tabs/components/wp-tabs/wp-tabs.component.sass
@@ -0,0 +1,7 @@
+.op-work-package-tabs
+ &_sticky
+ position: sticky
+ top: 0
+ background: white
+ z-index: 1
+ display: block
\ No newline at end of file