diff --git a/app/controllers/work_package_children_controller.rb b/app/controllers/work_package_children_controller.rb index 2c95e3cc8a39..a302af0fc4e9 100644 --- a/app/controllers/work_package_children_controller.rb +++ b/app/controllers/work_package_children_controller.rb @@ -58,7 +58,8 @@ def create 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 38095515fae5..6815f7c97e7e 100644 --- a/app/controllers/work_package_relations_controller.rb +++ b/app/controllers/work_package_relations_controller.rb @@ -60,10 +60,12 @@ def create .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 264732e1b6ee..4aa1aba25378 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;