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

bug/59458-activity-tab-does-not-scroll-to-the-bottom-or-correct-comment-on-mobile-fixed (#17458)

jjabari-op65704d3f41c6
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.ts
index 6df9b96efd3..22b42506438 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
@@ -380,11 +380,42 @@ export default class IndexController extends Controller {
this.tryScroll(activityId, 0, maxAttempts);
}
- private scrollToBottom() {
+ private tryScrollToBottom(attempts:number = 0, maxAttempts:number = 20) {
const scrollableContainer = this.getScrollableContainer();
- if (scrollableContainer) {
- scrollableContainer.scrollTop = scrollableContainer.scrollHeight;
+
+ if (!scrollableContainer) {
+ if (attempts < maxAttempts) {
+ setTimeout(() => this.tryScrollToBottom(attempts + 1, maxAttempts), 1000);
+ }
+ return;
}
+
+ scrollableContainer.scrollTop = 0;
+
+ let timeoutId:ReturnType<typeof setTimeout>;
+
+ const observer = new MutationObserver(() => {
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
+ clearTimeout(timeoutId);
+
+ timeoutId = setTimeout(() => {
+ observer.disconnect();
+ scrollableContainer.scrollTo({
+ top: scrollableContainer.scrollHeight,
+ behavior: 'smooth',
+ });
+ }, 100);
+ });
+
+ observer.observe(scrollableContainer, {
+ childList: true,
+ subtree: true,
+ attributes: true,
+ });
+ }
+
+ private scrollToBottom() {
+ this.tryScrollToBottom();
}
setFilterToOnlyComments() { this.filterValue = 'only_comments'; }