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

simple waiting mechanism in order to wait for anchor to be rendered in async request

Jonas Jabaric6f5f47d8386
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 ef02a67e404..9df5c036f22 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
@@ -355,15 +355,22 @@ export default class IndexController extends Controller {
}
}
- private scrollToActivity(activityId:string) {
+ private tryScroll(activityId:string, attempts:number, maxAttempts:number) {
const scrollableContainer = this.getScrollableContainer();
const activityElement = document.getElementById(`activity-anchor-${activityId}`);
if (activityElement && scrollableContainer) {
- scrollableContainer.scrollTop = activityElement.offsetTop-70;
+ scrollableContainer.scrollTop = activityElement.offsetTop - 70;
+ } else if (attempts < maxAttempts) {
+ setTimeout(() => this.tryScroll(activityId, attempts + 1, maxAttempts), 1000);
}
}
+ private scrollToActivity(activityId:string) {
+ const maxAttempts = 20; // wait max 20 seconds for the activity to be rendered
+ this.tryScroll(activityId, 0, maxAttempts);
+ }
+
private scrollToBottom() {
const scrollableContainer = this.getScrollableContainer();
if (scrollableContainer) {