BigW Consortium Gitlab

Commit b8a96fda by Phil Hughes

Fixed the preview keyboard shortcut focusing wrong tab

Closes #31101
parent f09f7539
......@@ -57,8 +57,11 @@ import findAndFollowLink from './shortcuts_dashboard_navigation';
Shortcuts.prototype.toggleMarkdownPreview = function(e) {
// Check if short-cut was triggered while in Write Mode
if ($(e.target).hasClass('js-note-text')) {
$('.js-md-preview-button').focus();
const $target = $(e.target);
const $form = $target.closest('form');
if ($target.hasClass('js-note-text')) {
$('.js-md-preview-button', $form).focus();
}
return $(document).triggerHandler('markdown-preview:toggle', [e]);
};
......
---
title: Fixued preview shortcut focusing wrong preview tab
merge_request:
author:
/* 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');
});
});
});
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