Skip to content

Commit 1293043

Browse files
committed
attachment: Fix drag and drop bug when to edit comment
1 parent 0c54435 commit 1293043

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

public/javascripts/common/yona.CommentAttachmentsUpdate.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,16 @@ $(function(){
7575
var $attachfiles = $parentForm.find(".temporaryUploadFiles");
7676
var $textarea = $parentForm.find("textarea");
7777

78-
if (doneCount === 0) {
78+
79+
if ($attachfiles.val() === "") {
7980
$attachfiles.val(data.id);
8081
} else {
81-
$attachfiles.val($attachfiles.val() + "," + data.id);
82+
var splitted = $attachfiles.val().split(",");
83+
if(!splitted.includes(data.id)) {
84+
$attachfiles.val(splitted.concat(data.id).join(","));
85+
}
8286
}
87+
8388
var attachment = '<div class="attached-file attached-file-marker" data-mime="' +
8489
data.mimeType.trim() + '" data-name="' + data.name + '" data-href="' + data.url + '">\n' +
8590
'<strong class="name">' + data.name + '</strong>\n' +
@@ -120,8 +125,6 @@ $(function(){
120125
var dt = e.originalEvent.dataTransfer;
121126
var files = dt.files;
122127

123-
console.log(files);
124-
125128
$(this).css("border", rememberBorder);
126129
$(this).parent().closest("form").find(".file-upload__input")[0].files = files;
127130
})

0 commit comments

Comments
 (0)