From 0cb8a3c56929583d59c22d99eaaf7db9d6eaba96 Mon Sep 17 00:00:00 2001 From: Evgeny Fadeev Date: Mon, 6 Apr 2026 17:24:25 -0400 Subject: [PATCH] fix for uploading multiple attachments in one editing session --- askbot/media/wmd/wmd.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/askbot/media/wmd/wmd.js b/askbot/media/wmd/wmd.js index 5d77c51c2c..dd378393eb 100644 --- a/askbot/media/wmd/wmd.js +++ b/askbot/media/wmd/wmd.js @@ -301,7 +301,11 @@ var WmdUploadDialog = function (opts) { this._makeLinkMarkdown = opts.makeLinkMarkdown; this.setFileType(opts.dialogType === 'file' ? 'attachment' : 'image'); - this.setInputId(util.makeId('file-upload')); + // Counter ensures each dialog instance gets a unique file-input ID. + // Never decremented: monotonic growth guarantees no ID collisions, + // even if the modal:after-close DOM cleanup hasn't fired yet. + WmdUploadDialog._counter += 1; + this.setInputId(util.makeId('file-upload-' + WmdUploadDialog._counter)); this._headerEnabled = true; this.setHeadingText(opts.headingText); @@ -310,6 +314,7 @@ var WmdUploadDialog = function (opts) { } }; inherits(WmdUploadDialog, FileUploadDialog); +WmdUploadDialog._counter = 0; WmdUploadDialog.prototype.createDom = function () { var me = this; @@ -326,6 +331,10 @@ WmdUploadDialog.prototype.createDom = function () { WmdUploadDialog.superClass_.createDom.call(this); + this._element.on('modal:after-close', function () { + me._element.remove(); + }); + // Override reject handler to also notify makeLinkMarkdown. // Must rebind the button because super createDom() already bound the original. var originalReject = me._reject_handler;