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

fix specified scrolling bug and added a spec for it, unclear other scrolling behaviour on mobile not related to activity tab discovered

Jonas Jabari144e17ebdc37
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.ts
index 22b42506438..4523445b58b 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
@@ -350,7 +350,7 @@ export default class IndexController extends Controller {
if (window.location.hash.includes('#activity-')) {
const activityId = window.location.hash.replace('#activity-', '');
this.scrollToActivity(activityId);
- } else if (this.sortingValue === 'asc') {
+ } else if (this.sortingValue === 'asc' && !this.isMobile()) {
this.scrollToBottom();
}
}
diff --git a/spec/features/activities/work_package/activities_spec.rb b/spec/features/activities/work_package/activities_spec.rb
index 83e1b3a5f85..d03634cddc7 100644
--- a/spec/features/activities/work_package/activities_spec.rb
+++ b/spec/features/activities/work_package/activities_spec.rb
@@ -922,24 +922,68 @@ RSpec.describe "Work package activity", :js, with_flag: { primerized_work_packag
wp_page.wait_for_activity_tab
end
- it "scrolls to the bottom when the newest journal entry is on the bottom", :aggregate_failures do
- sleep 1 # wait for auto scrolling to finish
- activity_tab.expect_journal_container_at_bottom
+ context "when on desktop" do
+ it "scrolls to the bottom when the newest journal entry is on the bottom", :aggregate_failures do
+ sleep 1 # wait for auto scrolling to finish
+ activity_tab.expect_journal_container_at_bottom
+
+ # auto-scrolls to the bottom when a new comment is added by the user
+ # add a comment
+ activity_tab.add_comment(text: "New comment by admin")
+ activity_tab.expect_journal_container_at_bottom
+
+ # auto-scrolls to the bottom when a new comment is added by another user
+ # add a comment
+ latest_journal_version = work_package.journals.last.version
+ create(:work_package_journal, user: member, notes: "New comment by member", journable: work_package,
+ version: latest_journal_version + 1)
+ # wait for the comment to be added
+ wait_for { page }.to have_test_selector("op-journal-notes-body", text: "New comment by member")
+ sleep 1 # wait for auto scrolling to finish
+ activity_tab.expect_journal_container_at_bottom
+ end
+ end
- # auto-scrolls to the bottom when a new comment is added by the user
- # add a comment
- activity_tab.add_comment(text: "New comment by admin")
- activity_tab.expect_journal_container_at_bottom
+ context "when on narrow desktop screen size" do
+ before do
+ page.current_window.resize_to(900, 1200)
+ # simulate a desktop screen which was resized to a smaller width
+ # the height in this spec is important as the activity tab must be visible
+ # otherwise the (in this case undesired) auto scrolling would not be triggered
- # auto-scrolls to the bottom when a new comment is added by another user
- # add a comment
- latest_journal_version = work_package.journals.last.version
- create(:work_package_journal, user: member, notes: "New comment by member", journable: work_package,
- version: latest_journal_version + 1)
- # wait for the comment to be added
- wait_for { page }.to have_test_selector("op-journal-notes-body", text: "New comment by member")
- sleep 1 # wait for auto scrolling to finish
- activity_tab.expect_journal_container_at_bottom
+ wp_page.visit!
+ wp_page.wait_for_activity_tab
+ end
+
+ it "does not scroll to the bottom when the newest journal entry is on the bottom", :aggregate_failures do
+ sleep 1 # wait for a potential auto scrolling to finish
+ # expect activity tab not to be visibe, as the page is not scrolled to the bottom
+ scroll_position = page.evaluate_script("document.querySelector(\"#content-body\").scrollTop")
+ expect(scroll_position).to eq(0)
+ end
+ end
+
+ context "when on mobile screen size" do
+ before do
+ page.current_window.resize_to(500, 1000)
+ # simulate a mobile screen size
+ # the height in this spec is important as the activity tab must be visible
+ # otherwise the (in this case undesired) auto scrolling would not be triggered
+
+ wp_page.visit!
+ wp_page.wait_for_activity_tab
+ end
+
+ # this one is actually failing, but it's not caused by the activity tab
+ # the scroll position is at around 700, some other part of the frontend code seems to trigger a scroll
+ # happens for the files tab as well for example
+ #
+ # it "does not scroll to the bottom when the newest journal entry is on the bottom", :aggregate_failures do
+ # sleep 1 # wait for a potential auto scrolling to finish
+ # # expect activity tab not to be visibe, as the page is not scrolled to the bottom
+ # scroll_position = page.evaluate_script("document.querySelector(\"#content-body\").scrollTop")
+ # expect(scroll_position).to eq(0)
+ # end
end
end