summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFilipa Lacerda <filipa@gitlab.com>2017-11-02 10:40:18 +0000
committerFilipa Lacerda <filipa@gitlab.com>2017-11-02 10:40:18 +0000
commit95f9f05378cf0e92fb3d3b67a217f8de8cde9227 (patch)
tree6b84b9e3b1381a67a91c5bf17bd37d9d9de1340e
parentdfe6c5390d73aff7b20876c3864524d49be74940 (diff)
parent0c49b5eb17a35a3b1929e5dc6decf9a1cc7bd910 (diff)
downloadgitlab-ce-95f9f05378cf0e92fb3d3b67a217f8de8cde9227.tar.gz
Merge branch 'jivl-fix-cancel-button-file-upload-new-issue' into 'master'
Fix cancel button not working when uploading a file on the new issue page Closes #39512 See merge request gitlab-org/gitlab-ce!15137
-rw-r--r--app/assets/javascripts/dropzone_input.js4
-rw-r--r--changelogs/unreleased/jivl-fix-cancel-button-file-upload-new-issue.yml5
-rw-r--r--spec/features/issues_spec.rb10
3 files changed, 16 insertions, 3 deletions
diff --git a/app/assets/javascripts/dropzone_input.js b/app/assets/javascripts/dropzone_input.js
index 7a17adcd44e..b7747ee3f83 100644
--- a/app/assets/javascripts/dropzone_input.js
+++ b/app/assets/javascripts/dropzone_input.js
@@ -119,11 +119,9 @@ export default function dropzoneInput(form) {
// removeAllFiles(true) stops uploading files (if any)
// and remove them from dropzone files queue.
$cancelButton.on('click', (e) => {
- const target = e.target.closest('.js-main-target-form').querySelector('.div-dropzone');
-
e.preventDefault();
e.stopPropagation();
- Dropzone.forElement(target).removeAllFiles(true);
+ Dropzone.forElement($formDropzone.get(0)).removeAllFiles(true);
});
// If 'error' event is fired, we store a failed files,
diff --git a/changelogs/unreleased/jivl-fix-cancel-button-file-upload-new-issue.yml b/changelogs/unreleased/jivl-fix-cancel-button-file-upload-new-issue.yml
new file mode 100644
index 00000000000..0205d9626b1
--- /dev/null
+++ b/changelogs/unreleased/jivl-fix-cancel-button-file-upload-new-issue.yml
@@ -0,0 +1,5 @@
+---
+title: Fix cancel button not working while uploading on the new issue page
+merge_request: 15137
+author:
+type: fixed
diff --git a/spec/features/issues_spec.rb b/spec/features/issues_spec.rb
index d4fd3a50008..9b94452fb0d 100644
--- a/spec/features/issues_spec.rb
+++ b/spec/features/issues_spec.rb
@@ -583,6 +583,16 @@ describe 'Issues' do
expect(page.find_field("issue_description").value).not_to match /\n\n$/
end
+
+ it "cancels a file upload correctly" do
+ dropzone_file([Rails.root.join('spec', 'fixtures', 'dk.png')], 0, false)
+
+ click_button 'Cancel'
+
+ expect(page).to have_button('Attach a file')
+ expect(page).not_to have_button('Cancel')
+ expect(page).not_to have_selector('.uploading-progress-container', visible: true)
+ end
end
context 'form filled by URL parameters' do