Commit 5ce39ad4 authored by Andrew Fontaine's avatar Andrew Fontaine

Merge branch '347497-fix-keyboard-shortcuts-on-issue-page' into 'master'

Fix issue sidebar keyboard shortcuts

See merge request gitlab-org/gitlab!76415
parents ffb5a56a 57abb1cd
......@@ -118,7 +118,10 @@ export default class ShortcutsIssuable extends Shortcuts {
// Wait for the sidebar to trigger('click') open
// so it doesn't cause our dropdown to close preemptively
setTimeout(() => {
document.querySelector(`.block.${name} .shortcut-sidebar-dropdown-toggle`).click();
const editBtn =
document.querySelector(`.block.${name} .shortcut-sidebar-dropdown-toggle`) ||
document.querySelector(`.block.${name} .edit-link`);
editBtn.click();
}, DEBOUNCE_DROPDOWN_DELAY);
return false;
}
......
......@@ -44,4 +44,90 @@ RSpec.describe 'Blob shortcuts', :js do
include_examples 'quotes the selected text'
end
end
shared_examples "opens assignee dropdown for editing" do
it "opens assignee dropdown for editing" do
find('body').native.send_key('a')
expect(find('.block.assignee')).to have_selector('.js-sidebar-assignee-data')
end
end
describe 'pressing "a"' do
describe 'On an Issue' do
before do
stub_feature_flags(issue_assignees_widget: false)
visit project_issue_path(project, issue)
wait_for_requests
end
include_examples 'opens assignee dropdown for editing'
end
describe 'On a Merge Request' do
before do
stub_feature_flags(issue_assignees_widget: false)
visit project_merge_request_path(project, merge_request)
wait_for_requests
end
include_examples 'opens assignee dropdown for editing'
end
end
shared_examples "opens milestones dropdown for editing" do
it "opens milestones dropdown for editing" do
find('body').native.send_key('m')
expect(find('[data-testid="milestone-edit"]')).to have_selector('.gl-new-dropdown-inner')
end
end
describe 'pressing "m"' do
describe 'On an Issue' do
before do
visit project_issue_path(project, issue)
wait_for_requests
end
include_examples 'opens milestones dropdown for editing'
end
describe 'On a Merge Request' do
before do
visit project_merge_request_path(project, merge_request)
wait_for_requests
end
include_examples 'opens milestones dropdown for editing'
end
end
shared_examples "opens labels dropdown for editing" do
it "opens labels dropdown for editing" do
find('body').native.send_key('l')
expect(find('.js-labels-block')).to have_selector('[data-testid="labels-select-dropdown-contents"]')
end
end
describe 'pressing "l"' do
describe 'On an Issue' do
before do
visit project_issue_path(project, issue)
wait_for_requests
end
include_examples 'opens labels dropdown for editing'
end
describe 'On a Merge Request' do
before do
visit project_merge_request_path(project, merge_request)
wait_for_requests
end
include_examples 'opens labels dropdown for editing'
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment