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
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
merged and fixed scroll behavior, fixed and refactored auto-scroll methods
Jonas Jabari80ad0e254222
diff --git a/app/components/work_packages/activities_tab/index_component.sass b/app/components/work_packages/activities_tab/index_component.sassindex d4c6750a2db..34fe6c22fb3 100644--- a/app/components/work_packages/activities_tab/index_component.sass+++ b/app/components/work_packages/activities_tab/index_component.sass@@ -1,4 +1,5 @@.work-packages-activities-tab-index-component+ overflow-y: hidden&--errorsposition: absolutewidth: calc(100% - 22px)diff --git a/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/index.controller.ts b/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/index.controller.tsindex 568d311ce93..89cbec08367 100644--- a/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/index.controller.ts+++ b/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/index.controller.ts@@ -165,7 +165,7 @@ export default class IndexController extends Controller {// otherwise the browser will perform an auto scroll to the before focused button after the stream update was appliedthis.unfocusReactionButtons();- const journalsContainerAtBottom = this.isJournalsContainerScrolledToBottom(this.journalsContainerTarget);+ const journalsContainerAtBottom = this.isJournalsContainerScrolledToBottom();void this.performUpdateStreamsRequest(this.prepareUpdateStreamsUrl()).then((html) => {@@ -272,7 +272,7 @@ export default class IndexController extends Controller {}private scrollToActivity(activityId:string) {- const scrollableContainer = jQuery(this.element).scrollParent()[0];+ const scrollableContainer = this.getScrollableContainer();const activityElement = document.getElementById(`activity-anchor-${activityId}`);if (activityElement && scrollableContainer) {@@ -281,7 +281,7 @@ export default class IndexController extends Controller {}private scrollToBottom() {- const scrollableContainer = jQuery(this.element).scrollParent()[0];+ const scrollableContainer = this.getScrollableContainer();if (scrollableContainer) {scrollableContainer.scrollTop = scrollableContainer.scrollHeight;}@@ -313,6 +313,19 @@ export default class IndexController extends Controller {return this.element.querySelector('.work-packages-activities-tab-journals-new-component');}+ private getScrollableContainer():HTMLElement | null {+ if (this.isWithinNotificationCenter()) {+ // valid for both mobile and desktop+ return document.querySelector('.work-package-details-tab') as HTMLElement;+ }+ if (this.isMobile()) {+ return document.querySelector('#content-body') as HTMLElement;+ }++ // valid for desktop+ return document.querySelector('.tabcontent') as HTMLElement;+ }+// Code Maintenance: Get rid of this JS based view port checks when activities are rendered in fully primierized activity tab in all contextsprivate isMobile():boolean {return window.innerWidth < 1279;@@ -350,18 +363,12 @@ export default class IndexController extends Controller {this.journalsContainerTarget.style.marginBottom = `${this.formRowTarget.clientHeight + 29}px`;}- private isJournalsContainerScrolledToBottom(journalsContainer:HTMLElement) {+ private isJournalsContainerScrolledToBottom() {let atBottom = false;// we have to handle different scrollable containers for different viewports/pages in order to idenfity if the user is at the bottom of the journals// DOM structure different for notification center and workpackage detail view as well- // seems way to hacky for me, but I couldn't find a better solution- if (this.isMobile() && !this.isWithinNotificationCenter()) {- const scrollableContainer = document.querySelector('#content-body') as HTMLElement;-- atBottom = (scrollableContainer.scrollTop + scrollableContainer.clientHeight + 10) >= scrollableContainer.scrollHeight;- } else {- const scrollableContainer = jQuery(journalsContainer).scrollParent()[0];-+ const scrollableContainer = this.getScrollableContainer();+ if (scrollableContainer) {atBottom = (scrollableContainer.scrollTop + scrollableContainer.clientHeight + 10) >= scrollableContainer.scrollHeight;}@@ -369,7 +376,7 @@ export default class IndexController extends Controller {}private scrollJournalContainer(journalsContainer:HTMLElement, toBottom:boolean, smooth:boolean = false) {- const scrollableContainer = jQuery(journalsContainer).scrollParent()[0];+ const scrollableContainer = this.getScrollableContainer();if (scrollableContainer) {if (smooth) {scrollableContainer.scrollTo({@@ -402,7 +409,7 @@ export default class IndexController extends Controller {}showForm() {- const journalsContainerAtBottom = this.isJournalsContainerScrolledToBottom(this.journalsContainerTarget);+ const journalsContainerAtBottom = this.isJournalsContainerScrolledToBottom();this.buttonRowTarget.classList.add('d-none');this.formRowTarget.classList.remove('d-none');