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

[#57904] meeting reload takes you back to your previous position

Tobias Dillmannb8e9d119a76d
diff --git a/frontend/src/stimulus/controllers/poll-for-changes.controller.ts b/frontend/src/stimulus/controllers/poll-for-changes.controller.ts
index b7b9407b582..0fc01cc7dd7 100644
--- a/frontend/src/stimulus/controllers/poll-for-changes.controller.ts
+++ b/frontend/src/stimulus/controllers/poll-for-changes.controller.ts
@@ -52,6 +52,9 @@ export default class PollForChangesController extends ApplicationController {
void this.triggerTurboStream();
}, this.intervalValue || 10_000);
}
+
+ window.addEventListener('beforeunload', this.rememberCurrentScrollPosition.bind(this));
+ window.addEventListener('DOMContentLoaded', this.autoscrollToLastKnownPosition.bind(this));
}
disconnect() {
@@ -73,4 +76,34 @@ export default class PollForChangesController extends ApplicationController {
}
});
}
+
+ rememberCurrentScrollPosition() {
+ const currentPosition = document.getElementById('content-body')?.scrollTop;
+
+ if (currentPosition !== undefined) {
+ sessionStorage.setItem(this.scrollPositionKey(), currentPosition.toString());
+ }
+ }
+
+ autoscrollToLastKnownPosition() {
+ const params = new URLSearchParams(window.location.search);
+ if (params.get('autoscroll') !== 'true') {
+ return;
+ }
+
+ const lastKnownPos = sessionStorage.getItem(this.scrollPositionKey());
+ if (lastKnownPos) {
+ const content = document.getElementById('content-body');
+
+ if (content) {
+ content.scrollTop = parseInt(lastKnownPos, 10);
+ }
+ }
+
+ sessionStorage.removeItem(this.scrollPositionKey());
+ }
+
+ private scrollPositionKey():string {
+ return `${this.urlValue}/scrollPosition`;
+ }
}
diff --git a/modules/meeting/app/components/meetings/update_flash_component.rb b/modules/meeting/app/components/meetings/update_flash_component.rb
index 31c991ed513..ad1996463f7 100644
--- a/modules/meeting/app/components/meetings/update_flash_component.rb
+++ b/modules/meeting/app/components/meetings/update_flash_component.rb
@@ -42,7 +42,7 @@ module Meetings
) do |banner|
banner.with_action_button(
tag: :a,
- href: helpers.meeting_path(meeting),
+ href: helpers.meeting_path(meeting, autoscroll: true),
data: { turbo: false },
size: :medium
) { I18n.t("label_meeting_reload") }