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

fixing reported bug and covered it with a spec

Jonas Jabaricfa789dd496a
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 80c8305a316..d0b00e45fc4 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
@@ -426,6 +426,8 @@ export default class IndexController extends Controller {
// scroll to (new) bottom if sorting is ascending and journals container was already at bottom before showing the form
this.scrollJournalContainer(true);
this.focusEditor();
+ } else {
+ this.focusEditor();
}
}
diff --git a/spec/features/activities/work_package/activities_spec.rb b/spec/features/activities/work_package/activities_spec.rb
index e5968834e57..b8ced544dd8 100644
--- a/spec/features/activities/work_package/activities_spec.rb
+++ b/spec/features/activities/work_package/activities_spec.rb
@@ -540,6 +540,30 @@ RSpec.describe "Work package activity", :js, :with_cuprite, with_flag: { primeri
end
end
+ describe "focus editor" do
+ current_user { admin }
+ let(:work_package) { create(:work_package, project:, author: admin) }
+
+ before do
+ wp_page.visit!
+ wp_page.wait_for_activity_tab
+ end
+
+ it "focuses the editor", :aggregate_failures do
+ activity_tab.set_journal_sorting(:desc)
+
+ activity_tab.open_new_comment_editor
+
+ activity_tab.expect_focus_on_editor
+
+ activity_tab.set_journal_sorting(:asc)
+
+ activity_tab.open_new_comment_editor
+
+ activity_tab.expect_focus_on_editor
+ end
+ end
+
describe "sorting" do
current_user { admin }
let(:work_package) { create(:work_package, project:, author: admin) }
diff --git a/spec/support/components/work_packages/activities.rb b/spec/support/components/work_packages/activities.rb
index cab633769ee..5f3601e6867 100644
--- a/spec/support/components/work_packages/activities.rb
+++ b/spec/support/components/work_packages/activities.rb
@@ -144,11 +144,21 @@ module Components
expect(page).not_to have_test_selector("op-work-package-journal-form")
end
+ def open_new_comment_editor
+ page.find_test_selector("op-open-work-package-journal-form-trigger").click
+ end
+
+ def expect_focus_on_editor
+ page.within_test_selector("op-work-package-journal-form-element") do
+ expect(page).to have_css(".ck-content:focus")
+ end
+ end
+
def add_comment(text: nil, save: true)
sleep 1 # otherwise the stimulus component is not mounted yet and the click does not work
if page.find_test_selector("op-open-work-package-journal-form-trigger")
- page.find_test_selector("op-open-work-package-journal-form-trigger").click
+ open_new_comment_editor
else
expect(page).to have_test_selector("op-work-package-journal-form-element")
end