Skip to content

Commit

Permalink
pass target relation for scrolling in relation and children controlle…
Browse files Browse the repository at this point in the history
…rs while creating a new relation or child
  • Loading branch information
bsatarnejad committed Dec 5, 2024
1 parent e1bfcd3 commit 6c71aed
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
3 changes: 2 additions & 1 deletion app/controllers/work_package_children_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
4 changes: 3 additions & 1 deletion app/controllers/work_package_relations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 6c71aed

Please sign in to comment.