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
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Ensure the right element is being scrolled to
Christophe Bliarda5c92d9ae97c
diff --git a/app/components/work_package_relations_tab/index_component.rb b/app/components/work_package_relations_tab/index_component.rbindex ae32398aec0..247cc519594 100644--- a/app/components/work_package_relations_tab/index_component.rb+++ b/app/components/work_package_relations_tab/index_component.rb@@ -1,5 +1,11 @@# frozen_string_literal: true+# Component for rendering the relations tab content of a work package+#+# This includes:+# - Controls for adding new relations if the user has permission+# - Related work packages grouped by relation type (follows, precedes, blocks, etc.)+# - Child work packagesclass WorkPackageRelationsTab::IndexComponent < ApplicationComponentFRAME_ID = "work-package-relations-tab-content"NEW_RELATION_ACTION_MENU = "new-relation-action-menu"@@ -11,6 +17,12 @@ class WorkPackageRelationsTab::IndexComponent < ApplicationComponentattr_reader :work_package, :relations, :children, :directionally_aware_grouped_relations, :relation_to_scroll_to+ # Initialize the component with required data+ #+ # @param work_package [WorkPackage] The work package whose relations are being displayed+ # @param relations [Array<Relation>] The relations associated with this work package+ # @param children [Array<WorkPackage>] Child work packages+ # @param relation_to_scroll_to [Relation, WorkPackage, nil] Optional relation or child to scroll to when renderingdef initialize(work_package:, relations:, children:, relation_to_scroll_to: nil)super()@@ -74,23 +86,31 @@ class WorkPackageRelationsTab::IndexComponent < ApplicationComponentdef render_items(border_box, items)items.each do |item|- data_attribute = if relation_to_scroll_to && item.id == relation_to_scroll_to.id- {- controller: "work-packages--relations-tab--scroll",- application_target: "dynamic",- "work-packages--relations-tab--scroll-target": "scrollToRow"- }- end-border_box.with_row(test_selector: row_test_selector(item),- data: data_attribute+ data: data_attribute(item)) doyield(item)endendend+ def data_attribute(item)+ if scroll_to?(item)+ {+ controller: "work-packages--relations-tab--scroll",+ application_target: "dynamic",+ "work-packages--relations-tab--scroll-target": "scrollToRow"+ }+ end+ end++ def scroll_to?(item)+ relation_to_scroll_to \+ && item.id == relation_to_scroll_to.id \+ && item.instance_of?(relation_to_scroll_to.class)+ end+def new_relation_path(relation_type:)raise ArgumentError, "Invalid relation type: #{relation_type}" unless Relation::TYPES.key?(relation_type)