notes.js: use the original content when resetting the form
Otherwise, when an error occurred, the content was escaped and re-escaped on every error. Fixes #37724
This commit is contained in:
parent
d0630ed38d
commit
1d30e5e964
2 changed files with 12 additions and 2 deletions
|
@ -1417,7 +1417,7 @@ export default class Notes {
|
|||
const isMainForm = $form.hasClass('js-main-target-form');
|
||||
const isDiscussionForm = $form.hasClass('js-discussion-note-form');
|
||||
const isDiscussionResolve = $submitBtn.hasClass('js-comment-resolve-button');
|
||||
const { formData, formContent, formAction } = this.getFormData($form);
|
||||
const { formData, formContent, formAction, formContentOriginal } = this.getFormData($form);
|
||||
let noteUniqueId;
|
||||
let systemNoteUniqueId;
|
||||
let hasQuickActions = false;
|
||||
|
@ -1576,7 +1576,7 @@ export default class Notes {
|
|||
$form = $notesContainer.parent().find('form');
|
||||
}
|
||||
|
||||
$form.find('.js-note-text').val(formContent);
|
||||
$form.find('.js-note-text').val(formContentOriginal);
|
||||
this.reenableTargetFormSubmitButton(e);
|
||||
this.addNoteError($form);
|
||||
});
|
||||
|
|
|
@ -103,6 +103,16 @@ import '~/notes';
|
|||
$('.js-comment-button').click();
|
||||
expect(this.autoSizeSpy).toHaveBeenTriggered();
|
||||
});
|
||||
|
||||
it('should not place escaped text in the comment box in case of error', function() {
|
||||
const deferred = $.Deferred();
|
||||
spyOn($, 'ajax').and.returnValue(deferred.promise());
|
||||
$(textarea).text('A comment with `markup`.');
|
||||
|
||||
deferred.reject();
|
||||
$('.js-comment-button').click();
|
||||
expect($(textarea).val()).toEqual('A comment with `markup`.');
|
||||
});
|
||||
});
|
||||
|
||||
describe('updateNote', () => {
|
||||
|
|
Loading…
Reference in a new issue