Fixed issue edit shortcut not working

This was caused by the element getting cached on the class before the
Vue app has finished rendering.

Closes #43560
This commit is contained in:
Phil Hughes 2018-02-26 14:12:38 +00:00
parent 7403ea37ad
commit 34c7938804
No known key found for this signature in database
GPG Key ID: 32245528C52E0F9F
3 changed files with 20 additions and 4 deletions

View File

@ -9,13 +9,12 @@ export default class ShortcutsIssuable extends Shortcuts {
super();
this.$replyField = isMergeRequest ? $('.js-main-target-form #note_note') : $('.js-main-target-form .js-vue-comment-form');
this.editBtn = document.querySelector('.js-issuable-edit');
Mousetrap.bind('a', () => ShortcutsIssuable.openSidebarDropdown('assignee'));
Mousetrap.bind('m', () => ShortcutsIssuable.openSidebarDropdown('milestone'));
Mousetrap.bind('l', () => ShortcutsIssuable.openSidebarDropdown('labels'));
Mousetrap.bind('r', this.replyWithSelectedText.bind(this));
Mousetrap.bind('e', this.editIssue.bind(this));
Mousetrap.bind('e', ShortcutsIssuable.editIssue);
if (isMergeRequest) {
this.enabledHelp.push('.hidden-shortcut.merge_requests');
@ -58,10 +57,10 @@ export default class ShortcutsIssuable extends Shortcuts {
return false;
}
editIssue() {
static editIssue() {
// Need to click the element as on issues, editing is inline
// on merge request, editing is on a different page
this.editBtn.click();
document.querySelector('.js-issuable-edit').click();
return false;
}

View File

@ -0,0 +1,5 @@
---
title: Fixed issue edit shortcut not opening edit form
merge_request:
author:
type: fixed

View File

@ -271,6 +271,18 @@ describe 'New/edit issue', :js do
end
end
context 'inline edit' do
before do
visit project_issue_path(project, issue)
end
it 'opens inline edit form with shortcut' do
find('body').send_keys('e')
expect(page).to have_selector('.detail-page-description form')
end
end
describe 'sub-group project' do
let(:group) { create(:group) }
let(:nested_group_1) { create(:group, parent: group) }