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
prevent auto-scroll to focused reaction button after update stream was applied
Jonas Jabarie6e349199461
diff --git a/app/components/work_packages/activities_tab/journals/item_component/reactions.html.erb b/app/components/work_packages/activities_tab/journals/item_component/reactions.html.erbindex 1d29d4e57fb..f627e6e1153 100644--- a/app/components/work_packages/activities_tab/journals/item_component/reactions.html.erb+++ b/app/components/work_packages/activities_tab/journals/item_component/reactions.html.erb@@ -12,7 +12,11 @@test_selector: "reaction-#{reaction}",tag: :a,href: href(reaction:),- data: { turbo_stream: true, turbo_method: :put },+ data: {+ turbo_stream: true,+ turbo_method: :put,+ "work-packages--activities-tab--index-target": "reactionButton",+ },aria: { label: aria_label_text(reaction, data[:users]) },disabled: current_user_cannot_react?,classes: "op-reactions-button"diff --git a/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/index.controller.ts b/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/index.controller.tsindex c5dc0af346c..568d311ce93 100644--- a/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/index.controller.ts+++ b/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/index.controller.ts@@ -23,12 +23,13 @@ export default class IndexController extends Controller {notificationCenterPathName: String,};- static targets = ['journalsContainer', 'buttonRow', 'formRow', 'form'];+ static targets = ['journalsContainer', 'buttonRow', 'formRow', 'form', 'reactionButton'];declare readonly journalsContainerTarget:HTMLElement;declare readonly buttonRowTarget:HTMLInputElement;declare readonly formRowTarget:HTMLElement;declare readonly formTarget:HTMLFormElement;+ declare readonly reactionButtonTargets:HTMLElement[];declare updateStreamsUrlValue:string;declare sortingValue:string;@@ -160,6 +161,10 @@ export default class IndexController extends Controller {this.updateInProgress = true;+ // Unfocus any reaction buttons that may have been focused+ // otherwise the browser will perform an auto scroll to the before focused button after the stream update was applied+ this.unfocusReactionButtons();+const journalsContainerAtBottom = this.isJournalsContainerScrolledToBottom(this.journalsContainerTarget);void this.performUpdateStreamsRequest(this.prepareUpdateStreamsUrl())@@ -172,6 +177,10 @@ export default class IndexController extends Controller {});}+ private unfocusReactionButtons() {+ this.reactionButtonTargets.forEach((button) => button.blur());+ }+private prepareUpdateStreamsUrl():string {const url = new URL(this.updateStreamsUrlValue);url.searchParams.set('sortBy', this.sortingValue);