Merge branch 'remove-double-newline-for-single-attachments' into 'master'
Only add newlines for multiple uploads Closes #29782 See merge request !10545
This commit is contained in:
commit
344a2619bb
3 changed files with 13 additions and 5 deletions
|
@ -66,7 +66,10 @@ window.DropzoneInput = (function() {
|
||||||
form_textarea.focus();
|
form_textarea.focus();
|
||||||
},
|
},
|
||||||
success: function(header, response) {
|
success: function(header, response) {
|
||||||
pasteText(response.link.markdown);
|
const processingFileCount = this.getQueuedFiles().length + this.getUploadingFiles().length;
|
||||||
|
const shouldPad = processingFileCount >= 1;
|
||||||
|
|
||||||
|
pasteText(response.link.markdown, shouldPad);
|
||||||
},
|
},
|
||||||
error: function(temp) {
|
error: function(temp) {
|
||||||
var checkIfMsgExists, errorAlert;
|
var checkIfMsgExists, errorAlert;
|
||||||
|
@ -123,9 +126,10 @@ window.DropzoneInput = (function() {
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
pasteText = function(text) {
|
pasteText = function(text, shouldPad) {
|
||||||
var afterSelection, beforeSelection, caretEnd, caretStart, textEnd;
|
var afterSelection, beforeSelection, caretEnd, caretStart, textEnd;
|
||||||
var formattedText = text + "\n\n";
|
var formattedText = text;
|
||||||
|
if (shouldPad) formattedText += "\n\n";
|
||||||
caretStart = $(child)[0].selectionStart;
|
caretStart = $(child)[0].selectionStart;
|
||||||
caretEnd = $(child)[0].selectionEnd;
|
caretEnd = $(child)[0].selectionEnd;
|
||||||
textEnd = $(child).val().length;
|
textEnd = $(child).val().length;
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
---
|
||||||
|
title: Only add newlines between multiple uploads
|
||||||
|
merge_request: 10545
|
||||||
|
author:
|
|
@ -601,10 +601,10 @@ describe 'Issues', feature: true do
|
||||||
expect(page.find_field("issue_description").value).to have_content 'banana_sample'
|
expect(page.find_field("issue_description").value).to have_content 'banana_sample'
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'adds double newline to end of attachment markdown' do
|
it "doesn't add double newline to end of a single attachment markdown" do
|
||||||
dropzone_file Rails.root.join('spec', 'fixtures', 'banana_sample.gif')
|
dropzone_file Rails.root.join('spec', 'fixtures', 'banana_sample.gif')
|
||||||
|
|
||||||
expect(page.find_field("issue_description").value).to match /\n\n$/
|
expect(page.find_field("issue_description").value).not_to match /\n\n$/
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue