parent
f09f753908
commit
b8a96fda9c
3 changed files with 38 additions and 2 deletions
|
@ -57,8 +57,11 @@ import findAndFollowLink from './shortcuts_dashboard_navigation';
|
||||||
|
|
||||||
Shortcuts.prototype.toggleMarkdownPreview = function(e) {
|
Shortcuts.prototype.toggleMarkdownPreview = function(e) {
|
||||||
// Check if short-cut was triggered while in Write Mode
|
// Check if short-cut was triggered while in Write Mode
|
||||||
if ($(e.target).hasClass('js-note-text')) {
|
const $target = $(e.target);
|
||||||
$('.js-md-preview-button').focus();
|
const $form = $target.closest('form');
|
||||||
|
|
||||||
|
if ($target.hasClass('js-note-text')) {
|
||||||
|
$('.js-md-preview-button', $form).focus();
|
||||||
}
|
}
|
||||||
return $(document).triggerHandler('markdown-preview:toggle', [e]);
|
return $(document).triggerHandler('markdown-preview:toggle', [e]);
|
||||||
};
|
};
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
---
|
||||||
|
title: Fixued preview shortcut focusing wrong preview tab
|
||||||
|
merge_request:
|
||||||
|
author:
|
29
spec/javascripts/shortcuts_spec.js
Normal file
29
spec/javascripts/shortcuts_spec.js
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
/* global Shortcuts */
|
||||||
|
describe('Shortcuts', () => {
|
||||||
|
const fixtureName = 'issues/open-issue.html.raw';
|
||||||
|
|
||||||
|
preloadFixtures(fixtureName);
|
||||||
|
|
||||||
|
describe('toggleMarkdownPreview', () => {
|
||||||
|
let sc;
|
||||||
|
let event;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
loadFixtures(fixtureName);
|
||||||
|
|
||||||
|
spyOnEvent('.js-md-preview-button', 'focus');
|
||||||
|
|
||||||
|
event = $.Event('', {
|
||||||
|
target: document.querySelector('.js-note-text'),
|
||||||
|
});
|
||||||
|
|
||||||
|
sc = new Shortcuts();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('focuses preview button in form', () => {
|
||||||
|
sc.toggleMarkdownPreview(event);
|
||||||
|
|
||||||
|
expect('focus').toHaveBeenTriggeredOn('.js-md-preview-button');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
Loading…
Reference in a new issue