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

pass target relation for scrolling in relation and children controllers while creating a new relation or child

Behrokh Satarnejadc15aef13b9c8
diff --git a/app/controllers/work_package_children_controller.rb b/app/controllers/work_package_children_controller.rb
index 2c95e3cc8a3..a302af0fc4e 100644
--- a/app/controllers/work_package_children_controller.rb
+++ b/app/controllers/work_package_children_controller.rb
@@ -58,7 +58,8 @@ class WorkPackageChildrenController < ApplicationController
component = WorkPackageRelationsTab::IndexComponent.new(
work_package: @work_package,
relations: @relations,
- children: @children
+ children: @children,
+ scroll_target_id: target_work_package_id
)
replace_via_turbo_stream(component:)
update_flash_message_via_turbo_stream(
diff --git a/app/controllers/work_package_relations_controller.rb b/app/controllers/work_package_relations_controller.rb
index 38095515fae..6815f7c97e7 100644
--- a/app/controllers/work_package_relations_controller.rb
+++ b/app/controllers/work_package_relations_controller.rb
@@ -60,10 +60,12 @@ class WorkPackageRelationsController < ApplicationController
.call(create_relation_params)
if service_result.success?
+ target_work_package_id = params[:relation][:to_id]
@work_package.reload
component = WorkPackageRelationsTab::IndexComponent.new(work_package: @work_package,
relations: @work_package.relations,
- children: @work_package.children)
+ children: @work_package.children,
+ scroll_target_id: target_work_package_id)
replace_via_turbo_stream(component:)
respond_with_turbo_streams
else
diff --git a/frontend/src/stimulus/controllers/dynamic/work-packages/relations-tab/scroll.controller.ts b/frontend/src/stimulus/controllers/dynamic/work-packages/relations-tab/scroll.controller.ts
index 264732e1b6e..4aa1aba2537 100644
--- a/frontend/src/stimulus/controllers/dynamic/work-packages/relations-tab/scroll.controller.ts
+++ b/frontend/src/stimulus/controllers/dynamic/work-packages/relations-tab/scroll.controller.ts
@@ -5,6 +5,7 @@ export default class ScrollController extends Controller {
declare targetIdValue:string;
connect() {
+ // Wait to ensure DOM is fully loaded
setTimeout(() => {
if (this.targetIdValue) {
const element = document.querySelector(`[data-test-selector='op-relation-row-${this.targetIdValue}']`) as HTMLElement;