Commit 70aec343 authored by Brett Walker's avatar Brett Walker

Properly turn off markdown keydown listener

 for specific text area
parent f0402e3f
...@@ -332,13 +332,12 @@ export function keypressNoteText(e) { ...@@ -332,13 +332,12 @@ export function keypressNoteText(e) {
select: '', select: '',
tagContent: '', tagContent: '',
}); });
} }
} }
/* eslint-enable @gitlab/require-i18n-strings */ /* eslint-enable @gitlab/require-i18n-strings */
export function addMarkdownListeners(form) { export function addMarkdownListeners(form) {
$('.markdown-area').on('keydown', keypressNoteText); $('.markdown-area', form).on('keydown', keypressNoteText);
return $('.js-md', form) return $('.js-md', form)
.off('click') .off('click')
.on('click', function() { .on('click', function() {
...@@ -377,6 +376,6 @@ export function addEditorMarkdownListeners(editor) { ...@@ -377,6 +376,6 @@ export function addEditorMarkdownListeners(editor) {
} }
export function removeMarkdownListeners(form) { export function removeMarkdownListeners(form) {
$('.markdown-area').off('keydown'); $('.markdown-area', form).off('keydown', keypressNoteText);
return $('.js-md', form).off('click'); return $('.js-md', form).off('click');
} }
--- ---
title: Surround selected text in markdown fields on certain key presses title: Surround selected text in markdown fields on certain key presses
merge_request: 25748 merge_request: 37151
author: author:
type: added type: added
...@@ -8,6 +8,7 @@ RSpec.describe 'Projects > Wiki > User previews markdown changes', :js do ...@@ -8,6 +8,7 @@ RSpec.describe 'Projects > Wiki > User previews markdown changes', :js do
let(:wiki_page) { create(:wiki_page, wiki: project.wiki, title: 'home', content: '[some link](other-page)') } let(:wiki_page) { create(:wiki_page, wiki: project.wiki, title: 'home', content: '[some link](other-page)') }
let(:wiki_content) do let(:wiki_content) do
<<-HEREDOC <<-HEREDOC
Some text so key event for [ does not trigger an incorrect replacement.
[regular link](regular) [regular link](regular)
[relative link 1](../relative) [relative link 1](../relative)
[relative link 2](./relative) [relative link 2](./relative)
......
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