Skip to content

Commit

Permalink
Merge pull request #17150 from opf/bug/59082-the-comment-box-in-activ…
Browse files Browse the repository at this point in the history
…ity-requires-a-second-click-for-keyboard-focus

Bug/59082 the comment box in activity requires a second click for keyboard focus
  • Loading branch information
akabiru authored Nov 8, 2024
2 parents e8d8bb1 + b018e2b commit 868463f
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,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();
}
}

Expand Down
24 changes: 24 additions & 0 deletions spec/features/activities/work_package/activities_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,30 @@
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) }
Expand Down
16 changes: 11 additions & 5 deletions spec/support/components/work_packages/activities.rb
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,19 @@ def expect_no_input_field
expect(page).not_to have_test_selector("op-work-package-journal-form")
end

def add_comment(text: nil, save: true)
sleep 1 # otherwise the stimulus component is not mounted yet and the click does not work
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)
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
Expand Down Expand Up @@ -182,8 +190,6 @@ def edit_comment(journal, text: nil)
end

def quote_comment(journal)
sleep 1 # otherwise the stimulus component is not mounted yet and the click does not work

within_journal_entry(journal) do
page.find_test_selector("op-wp-journal-#{journal.id}-action-menu").click
page.find_test_selector("op-wp-journal-#{journal.id}-quote").click
Expand Down

0 comments on commit 868463f

Please sign in to comment.